static void test_check_slices_after_adding_all(void) { static const char *gladiators[] = { "Spartacus", "C r i x u s", "Priscus and Verus", "Tetraites", "Spiculus", "Marcus Attilius", "Carpophorus", "Flamma", "Commodus", "Mevia", "Hoplomachus", "Laquearius", "Lorarius", "Paegniarius", "Sagittarius", "Pegasasu no Seiya", "Thraex", "Gladiatrix", "Crupellarii", "Cestus", "Arbelas", "Retiarius", "Samnite", "Venator", "Dimachaerus", "Bustuarius", "This is a loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong name for a gladiator" }; struct sol_arena *arena; struct sol_str_slice results[sol_util_array_size(gladiators)]; unsigned int i; arena = sol_arena_new(); ASSERT(arena); for (i = 0; i < sol_util_array_size(gladiators); i++) ASSERT_INT_EQ(sol_arena_slice_dup_str(arena, &results[i], gladiators[i]), 0); for (i = 0; i < sol_util_array_size(gladiators); i++) ASSERT(sol_str_slice_eq(results[i], sol_str_slice_from_str(gladiators[i]))); sol_arena_del(arena); }
static void shutdown(void) { if (the_runner) runner_del(the_runner); if (str_arena) sol_arena_del(str_arena); sol_ptr_vector_clear(&args.fbp_search_paths); }
static void test_null(void) { struct sol_arena *arena; struct sol_str_slice dst; arena = sol_arena_new(); ASSERT(arena); ASSERT(sol_arena_slice_dup_str(arena, &dst, NULL)); ASSERT(sol_arena_slice_dup_str_n(arena, &dst, NULL, 0)); ASSERT(sol_arena_slice_dup(arena, &dst, SOL_STR_SLICE_STR(NULL, 0))); ASSERT(!sol_arena_strdup(arena, NULL)); ASSERT(!sol_arena_strndup(arena, NULL, 0)); sol_arena_del(arena); }
static void test_simple(void) { static const char *gladiators[] = { "Spartacus", "C r i x u s", "Priscus and Verus" }; struct sol_arena *arena; struct sol_str_slice dst; char *dst_str; unsigned int i; arena = sol_arena_new(); ASSERT(arena); for (i = 0; i < sol_util_array_size(gladiators); i++) { struct sol_str_slice gladiator_slice = sol_str_slice_from_str(gladiators[i]); ASSERT_INT_EQ(sol_arena_slice_dup_str(arena, &dst, gladiators[i]), 0); ASSERT(sol_str_slice_eq(dst, gladiator_slice)); ASSERT_INT_EQ(sol_arena_slice_dup_str_n(arena, &dst, gladiators[i], strlen(gladiators[i])), 0); ASSERT(sol_str_slice_eq(dst, gladiator_slice)); ASSERT_INT_EQ(sol_arena_slice_dup(arena, &dst, sol_str_slice_from_str(gladiators[i])), 0); ASSERT(sol_str_slice_eq(dst, gladiator_slice)); dst_str = sol_arena_strdup(arena, gladiators[i]); ASSERT(dst_str); ASSERT(streq(gladiators[i], dst_str)); dst_str = sol_arena_strndup(arena, gladiators[i], strlen(gladiators[i])); ASSERT(dst_str); ASSERT(streq(gladiators[i], dst_str)); } sol_arena_del(arena); }