+
+ bt_ctf_field_type_integer_set_signed(int_64_type, 1);
+ ok(int_64_type, "Create a signed integer type");
+ enum_type = bt_ctf_field_type_enumeration_create(int_64_type);
+
+ returned_type = bt_ctf_field_type_enumeration_get_container_type(enum_type);
+ ok(returned_type == int_64_type, "bt_ctf_field_type_enumeration_get_container_type returns the right type");
+ ok(!bt_ctf_field_type_enumeration_get_container_type(NULL), "bt_ctf_field_type_enumeration_get_container_type handles NULL correctly");
+ ok(!bt_ctf_field_type_enumeration_create(enum_type),
+ "bt_ctf_field_enumeration_type_create rejects non-integer container field types");
+ bt_ctf_field_type_put(returned_type);
+
+ bt_ctf_field_type_set_alignment(float_type, 32);
+ ok(bt_ctf_field_type_get_alignment(NULL) < 0,
+ "bt_ctf_field_type_get_alignment handles NULL correctly");
+ ok(bt_ctf_field_type_get_alignment(float_type) == 32,
+ "bt_ctf_field_type_get_alignment returns a correct value");
+
+ ok(bt_ctf_field_type_floating_point_set_exponent_digits(float_type, 11) == 0,
+ "Set a floating point type's exponent digit count");
+ ok(bt_ctf_field_type_floating_point_set_mantissa_digits(float_type, 53) == 0,
+ "Set a floating point type's mantissa digit count");
+
+ ok(bt_ctf_field_type_floating_point_get_exponent_digits(NULL) < 0,
+ "bt_ctf_field_type_floating_point_get_exponent_digits handles NULL properly");
+ ok(bt_ctf_field_type_floating_point_get_mantissa_digits(NULL) < 0,
+ "bt_ctf_field_type_floating_point_get_mantissa_digits handles NULL properly");
+ ok(bt_ctf_field_type_floating_point_get_exponent_digits(float_type) == 11,
+ "bt_ctf_field_type_floating_point_get_exponent_digits returns the correct value");
+ ok(bt_ctf_field_type_floating_point_get_mantissa_digits(float_type) == 53,
+ "bt_ctf_field_type_floating_point_get_mantissa_digits returns the correct value");
+
+ ok(bt_ctf_field_type_enumeration_add_mapping(enum_type,
+ mapping_name_negative_test, -12345, 0) == 0,
+ "bt_ctf_field_type_enumeration_add_mapping accepts negative enumeration mappings");
+ ok(bt_ctf_field_type_enumeration_add_mapping(enum_type,
+ "escaping; \"test\"", 1, 1) == 0,
+ "bt_ctf_field_type_enumeration_add_mapping accepts enumeration mapping strings containing quotes");
+ ok(bt_ctf_field_type_enumeration_add_mapping(enum_type,
+ "\tanother \'escaping\'\n test\"", 2, 4) == 0,
+ "bt_ctf_field_type_enumeration_add_mapping accepts enumeration mapping strings containing special characters");
+ ok(bt_ctf_field_type_enumeration_add_mapping(enum_type,
+ "event clock int float", 5, 22) == 0,
+ "Accept enumeration mapping strings containing reserved keywords");
+ bt_ctf_field_type_enumeration_add_mapping(enum_type, mapping_name_test,
+ 42, 42);
+ ok(bt_ctf_field_type_enumeration_add_mapping(enum_type, mapping_name_test,
+ 43, 51), "bt_ctf_field_type_enumeration_add_mapping rejects duplicate mapping names");
+ ok(bt_ctf_field_type_enumeration_add_mapping(enum_type, "something",
+ -500, -400), "bt_ctf_field_type_enumeration_add_mapping rejects overlapping enum entries");
+ ok(bt_ctf_field_type_enumeration_add_mapping(enum_type, mapping_name_test,
+ -54, -55), "bt_ctf_field_type_enumeration_add_mapping rejects mapping where end < start");
+ bt_ctf_field_type_enumeration_add_mapping(enum_type, "another entry", -42000, -13000);
+
+ ok(bt_ctf_field_type_enumeration_get_mapping_index_by_value(NULL, -42) < 0,
+ "bt_ctf_field_type_enumeration_get_mapping_index_by_value handles a NULL field type correctly");
+ ok(bt_ctf_field_type_enumeration_get_mapping_index_by_value(enum_type, 1000000) < 0,
+ "bt_ctf_field_type_enumeration_get_mapping_index_by_value handles invalid values correctly");
+ ok(bt_ctf_field_type_enumeration_get_mapping_index_by_value(enum_type, -55) == 1,
+ "bt_ctf_field_type_enumeration_get_mapping_index_by_value returns the correct index");
+
+ ok(bt_ctf_event_class_add_field(simple_event_class, enum_type,
+ "enum_field") == 0, "Add signed enumeration field to event");
+
+ ok(bt_ctf_field_type_enumeration_get_mapping(NULL, 0, &ret_char,
+ &ret_range_start_int64_t, &ret_range_end_int64_t) < 0,
+ "bt_ctf_field_type_enumeration_get_mapping handles a NULL enumeration correctly");
+ ok(bt_ctf_field_type_enumeration_get_mapping(enum_type, 0, NULL,
+ &ret_range_start_int64_t, &ret_range_end_int64_t) < 0,
+ "bt_ctf_field_type_enumeration_get_mapping handles a NULL string correctly");
+ ok(bt_ctf_field_type_enumeration_get_mapping(enum_type, 0, &ret_char,
+ NULL, &ret_range_end_int64_t) < 0,
+ "bt_ctf_field_type_enumeration_get_mapping handles a NULL start correctly");
+ ok(bt_ctf_field_type_enumeration_get_mapping(enum_type, 0, &ret_char,
+ &ret_range_start_int64_t, NULL) < 0,
+ "bt_ctf_field_type_enumeration_get_mapping handles a NULL end correctly");
+ ok(bt_ctf_field_type_enumeration_get_mapping(enum_type, 5, &ret_char,
+ &ret_range_start_int64_t, &ret_range_end_int64_t) == 0,
+ "bt_ctf_field_type_enumeration_get_mapping returns a value");
+ ok(!strcmp(ret_char, mapping_name_test),
+ "bt_ctf_field_type_enumeration_get_mapping returns a correct mapping name");
+ ok(ret_range_start_int64_t == 42,
+ "bt_ctf_field_type_enumeration_get_mapping returns a correct mapping start");
+ ok(ret_range_end_int64_t == 42,
+ "bt_ctf_field_type_enumeration_get_mapping returns a correct mapping end");
+
+ ok(bt_ctf_field_type_enumeration_add_mapping_unsigned(enum_type_unsigned,
+ "escaping; \"test\"", 0, 0) == 0,
+ "bt_ctf_field_type_enumeration_add_mapping_unsigned accepts enumeration mapping strings containing quotes");
+ ok(bt_ctf_field_type_enumeration_add_mapping_unsigned(enum_type_unsigned,
+ "\tanother \'escaping\'\n test\"", 1, 4) == 0,
+ "bt_ctf_field_type_enumeration_add_mapping_unsigned accepts enumeration mapping strings containing special characters");
+ ok(bt_ctf_field_type_enumeration_add_mapping_unsigned(enum_type_unsigned,
+ "event clock int float", 5, 22) == 0,
+ "bt_ctf_field_type_enumeration_add_mapping_unsigned accepts enumeration mapping strings containing reserved keywords");
+ bt_ctf_field_type_enumeration_add_mapping_unsigned(enum_type_unsigned, mapping_name_test,
+ 42, 42);
+ ok(bt_ctf_field_type_enumeration_add_mapping_unsigned(enum_type_unsigned, mapping_name_test,
+ 43, 51), "bt_ctf_field_type_enumeration_add_mapping_unsigned rejects duplicate mapping names");
+ ok(bt_ctf_field_type_enumeration_add_mapping_unsigned(enum_type_unsigned, "something",
+ 7, 8), "bt_ctf_field_type_enumeration_add_mapping_unsigned rejects overlapping enum entries");
+ ok(bt_ctf_field_type_enumeration_add_mapping_unsigned(enum_type_unsigned, mapping_name_test,
+ 55, 54), "bt_ctf_field_type_enumeration_add_mapping_unsigned rejects mapping where end < start");
+ ok(bt_ctf_event_class_add_field(simple_event_class, enum_type_unsigned,
+ "enum_field_unsigned") == 0, "Add unsigned enumeration field to event");
+
+ ok(bt_ctf_field_type_enumeration_get_mapping_count(NULL) < 0,
+ "bt_ctf_field_type_enumeration_get_mapping_count handles NULL correctly");
+ ok(bt_ctf_field_type_enumeration_get_mapping_count(enum_type_unsigned) == 4,
+ "bt_ctf_field_type_enumeration_get_mapping_count returns the correct value");
+
+ ok(bt_ctf_field_type_enumeration_get_mapping_unsigned(NULL, 0, &ret_char,
+ &ret_range_start_uint64_t, &ret_range_end_uint64_t) < 0,
+ "bt_ctf_field_type_enumeration_get_mapping_unsigned handles a NULL enumeration correctly");
+ ok(bt_ctf_field_type_enumeration_get_mapping_unsigned(enum_type_unsigned, 0, NULL,
+ &ret_range_start_uint64_t, &ret_range_end_uint64_t) < 0,
+ "bt_ctf_field_type_enumeration_get_mapping_unsigned handles a NULL string correctly");
+ ok(bt_ctf_field_type_enumeration_get_mapping_unsigned(enum_type_unsigned, 0, &ret_char,
+ NULL, &ret_range_end_uint64_t) < 0,
+ "bt_ctf_field_type_enumeration_get_mapping_unsigned handles a NULL start correctly");
+ ok(bt_ctf_field_type_enumeration_get_mapping_unsigned(enum_type_unsigned, 0, &ret_char,
+ &ret_range_start_uint64_t, NULL) < 0,
+ "bt_ctf_field_type_enumeration_get_mapping_unsigned handles a NULL end correctly");
+ ok(bt_ctf_field_type_enumeration_get_mapping_unsigned(enum_type_unsigned, 3, &ret_char,
+ &ret_range_start_uint64_t, &ret_range_end_uint64_t) == 0,
+ "bt_ctf_field_type_enumeration_get_mapping_unsigned returns a value");
+ ok(!strcmp(ret_char, mapping_name_test),
+ "bt_ctf_field_type_enumeration_get_mapping_unsigned returns a correct mapping name");
+ ok(ret_range_start_uint64_t == 42,
+ "bt_ctf_field_type_enumeration_get_mapping_unsigned returns a correct mapping start");
+ ok(ret_range_end_uint64_t == 42,
+ "bt_ctf_field_type_enumeration_get_mapping_unsigned returns a correct mapping end");
+