static void testInsert() { // test general case Hash_T h0 = Hash_new(0); EXPECT_EQ_UINT32(0, h0->nElements); EXPECT_EQ_UINT32(0, h0->tableSize); int key1 = 123; char* value1 = "1"; h0 = Hash_insert(h0, Atom_newFromInt64(key1), value1); EXPECT_NOT_NULL(h0); EXPECT_EQ_UINT32(1, h0->nElements); EXPECT_EQ_UINT32(1, h0->tableSize); int key2 = -27; char value2[] = "value2"; h0 = Hash_insert(h0, Atom_newFromInt64(key2), value2); EXPECT_NOT_NULL(h0); EXPECT_EQ_UINT32(2, h0->nElements); EXPECT_EQ_UINT32(3, h0->tableSize); char * key3 = "abc"; int16_t value3 = 1056; Str_T s = Str_newFromInt16(value3); h0 = Hash_insert(h0, Atom_newFromString(key3), Str_str(s)); EXPECT_NOT_NULL(h0); EXPECT_EQ_UINT32(3, h0->nElements); EXPECT_EQ_UINT32(3, h0->tableSize); Str_free(&s); Hash_free(&h0); EXPECT_NULL(h0); }
static void Str_get_num_dec_real__hasString__return_num_dec_real(void **state){ char * str ="0.77...9k9.8"; Str_t *test_str = Str_s_new(str); int res = Str_get_num_dec_real(test_str); assert_int_equal(res, 2); Str_free(test_str); }
static void Str_new__hasString__returnsStr_t(void **state){ int res; int res1; char * null_test_str=""; char * ok_test_str ="23.yy"; Str_t *test_str = Str_s_new(null_test_str); Str_t *test_str_1 = Str_s_new(ok_test_str); if (Str_get_string(test_str)){ res = 0; } else{ res=1; } if (Str_get_string(test_str_1)){ res1 = 1; } else{ res1=0; } assert_int_equal(res, 0); assert_int_equal(res1, 1); Str_free(test_str); Str_free(test_str_1); }
static void testInt16() { // test all APIs for type int16_t const unsigned trace = 0; Str_T s = Str_newFromInt16(27); EXPECT_NOT_NULL(s); char *cP = Str_str(s); EXPECT_NOT_NULL(cP); EXPECT_TRUE(strcmp("int16_t", s->valueTypeName) == 0); EXPECT_EQ_INT16(27, Str_valueInt16(s)); if (trace) // "s as str should be funny" fprintf(stderr, "s as str: %s as int16: %d\n", Str_str(s), Str_valueInt16(s)); Str_free(&s); EXPECT_NULL(s); }