Commit 2069835b authored by Matthias Simon's avatar Matthias Simon
Browse files

Add core language tests

parent 92f117c3
Loading
Loading
Loading
Loading
+29 −0
Original line number Original line Diff line number Diff line
/***************************************************
 ** @author   TTF T014
 ** @version  0.0.1
 ** @purpose  1:6.2.1.3, Verify that it is possible to use a nested structured type as a field of a record
 ** @verdict  pass accept, noexecution
 ***************************************************/

// The following requirement is tested:
// TTCN 3 supports the definition of types for record fields nested within the record definition.
// ... the definition of new structured types (record, set, enumerated, set of, record of, and union
// and map) ...

module Sem_06020103_nested_type_definitions_for_field_types_001 {
    // Example from the specification, 1st part
	type record MyNestedRecordType
	{
		record
		{
			integer nestedField1,
			float nestedField2
		} outerField1,
		enumerated {
			nestedEnum1,
			nestedEnum2
		} outerField2,
		record of boolean outerField3,
		map from charstring to charstring outerfield4
	};
}
+19 −0
Original line number Original line Diff line number Diff line
/***************************************************
 ** @author   TTF T014
 ** @version  0.0.1
 ** @purpose  1:6.2.1.3, Verify that it is possible to use a nested subtype constraints for record fields
 ** @verdict  pass accept, noexecution
 ***************************************************/

// The following requirement is tested:
// TTCN 3 supports the definition of types for record fields nested within the record definition.
// ... the specification of subtype constraints [is] possible.

module Sem_06020103_nested_type_definitions_for_field_types_002 {
    // Example from the specification, 2nd part
	type record MyRecordTypeWithSubtypedFields
	{
		integer    field1 (1 .. 100),
		charstring field2 length ( 2 .. 255 )
	}
}
+31 −0
Original line number Original line Diff line number Diff line
/***************************************************
 ** @author   TTF T014
 ** @version  0.0.1
 ** @purpose  1:6.2.15.5, Verify that map keys are unique
 ** @verdict  pass accept, ttcn3result: pass
 ***************************************************/

// The following requirement is tested:
// Since there is at most one value mapped to each key in a map value, the values in the set of keys
// will be unique. The length of the map value is equal to the length of the set of keys.

module Sem_06021505_accessing_the_keys_003 {
	type map from charstring to integer TMap1;
	type component C {}

	testcase TC_Sem_06021505_accessing_the_keys_003() runs on C {
		var TMap1 v_map;
		v_map["test"] := 1;
		v_map["xyz"] := 5;
		v_map["test"] := 6;
		if (match(v_map.from, { "test", "xyz" }) and lengthof(v_map.from == 2)) {
			setverdict(pass);
		} else {
			setverdict(fail);
		}
	}

	control {
		execute(TC_Sem_06021505_accessing_the_keys_002());
	}
}
+30 −0
Original line number Original line Diff line number Diff line
/***************************************************
 ** @author   TTF T014
 ** @version  0.0.1
 ** @purpose  1:6.2.15.6, Verify that map values don't have to be unique
 ** @verdict  pass accept, ttcn3result: pass
 ***************************************************/

// The following requirement is tested:
// Since two different keys might be mapped to the same value in a map value, the values in the set of
// values might not be unique. The set of values will contain one value for each key value pair in
// the map. The length of the map value is equal to the length of the set of values.

module Sem_06021506_accessing_the_values_003 {
	type map from charstring to integer MapValueType;
	type component C {}

	testcase TC_Sem_06021506_accessing_the_values_003() runs on C {
		var MapValueType v_map := { [a] := 0, [b] := 0, [c] := 1 };
		var MapValueType.to v_values := v_map.to;
		if (match(v_values, {0,1,0})) { // yields true
			setverdict(pass);
		} else {
			setverdict(fail);
		}
	}

	control {
		execute(TC_Sem_06021506_accessing_the_values_003());
	}
}
+28 −0
Original line number Original line Diff line number Diff line
/*****************************************************************
 ** @author   TTF 014
 ** @version  0.0.1
 ** @purpose  1:15.6.1, Ensure that the referencing of individual string elements inside templates or template fields is allowed on the left hand side.
 ** @verdict  pass reject
 *****************************************************************/

module NegSem_150601_ReferencingIndividualStringElements_001 {

type component GeneralComp { }

testcase TC_NegSem_150601_ReferencingIndividualStringElements_001() runs on GeneralComp {
	var template charstring v_char1 := "abc";

    v_char1[2] := "test"; // will produce an error as the character string contains more than one character

    if (v_char1.value == "abtest") {
		setverdict(pass);
	} else {
		setverdict(fail);
	}
}

control{
    execute(TC_NegSem_150601_ReferencingIndividualStringElements_001());
}

}
 No newline at end of file
Loading