/trunk/Examples/test-suite/octave/unions_runme.m
Objective C | 49 lines | 38 code | 11 blank | 0 comment | 12 complexity | eb5f9236f4721e9773924261d7c6b97e MD5 | raw file
1 2# This is the union runtime testcase. It ensures that values within a 3# union embedded within a struct can be set and read correctly. 4 5unions 6 7# Create new instances of SmallStruct and BigStruct for later use 8small = unions.SmallStruct(); 9small.jill = 200; 10 11big = unions.BigStruct(); 12big.smallstruct = small; 13big.jack = 300; 14 15# Use SmallStruct then BigStruct to setup EmbeddedUnionTest. 16# Ensure values in EmbeddedUnionTest are set correctly for each. 17eut = unions.EmbeddedUnionTest(); 18 19# First check the SmallStruct in EmbeddedUnionTest 20eut.number = 1; 21eut.uni.small = small; 22Jill1 = eut.uni.small.jill; 23if (Jill1 != 200) 24 error("Runtime test1 failed. eut.uni.small.jill=%i" , Jill1) 25endif 26 27Num1 = eut.number; 28if (Num1 != 1) 29 error("Runtime test2 failed. eut.number=%i" , Num1) 30endif 31 32# Secondly check the BigStruct in EmbeddedUnionTest 33eut.number = 2; 34eut.uni.big = big; 35Jack1 = eut.uni.big.jack; 36if (Jack1 != 300) 37 error("Runtime test3 failed. eut.uni.big.jack=%i" , Jack1) 38endif 39 40Jill2 = eut.uni.big.smallstruct.jill; 41if (Jill2 != 200) 42 error("Runtime test4 failed. eut.uni.big.smallstruct.jill=%i" , Jill2) 43endif 44 45Num2 = eut.number; 46if (Num2 != 2) 47 error("Runtime test5 failed. eut.number=%i" , Num2) 48endif 49