void popping_item_takes_us_back_to_the_previous_item() { Breadcrumb *breadcrumb = create_breadcrumb(); push_breadcrumb(breadcrumb, "Hello"); push_breadcrumb(breadcrumb, "Goodbye"); pop_breadcrumb(breadcrumb); assert_string_equal(get_current_from_breadcrumb(breadcrumb), "Hello"); }
TestReporter *create_reporter() { CgreenBreadcrumb *breadcrumb; TestReporter *reporter = (TestReporter *) malloc(sizeof(TestReporter)); if (reporter == NULL) { return NULL; } breadcrumb = create_breadcrumb(); if (breadcrumb == NULL) { free(reporter); return NULL; } reporter->destroy = &destroy_reporter; reporter->start_suite = &reporter_start_suite; reporter->start_test = &reporter_start; reporter->show_pass = &show_pass; reporter->show_fail = &show_fail; reporter->show_incomplete = &show_incomplete; reporter->assert_true = &assert_true; reporter->finish_test = &reporter_finish; reporter->finish_suite = &reporter_finish_suite; reporter->passes = 0; reporter->failures = 0; reporter->exceptions = 0; reporter->breadcrumb = breadcrumb; reporter->memo = NULL; reporter->options = NULL; return reporter; }
void double_item_breadcrumb_does_calls_walker_only_once() { expect(mock_walker, want_string(name, "Hello")); expect(mock_walker, want_string(name, "Goodbye")); Breadcrumb *breadcrumb = create_breadcrumb(); push_breadcrumb(breadcrumb, "Hello"); push_breadcrumb(breadcrumb, "Goodbye"); walk_breadcrumb(breadcrumb, &mock_walker, NULL); }
TestReporter *create_reporter() { TestReporter *reporter = (TestReporter *)malloc(sizeof(TestReporter)); reporter->destroy = &destroy_reporter; reporter->start = &reporter_start; reporter->finish = &reporter_finish; reporter->show_pass = &show_pass; reporter->show_fail = &show_fail; reporter->show_incomplete = &show_incomplete; reporter->assert_true = &assert_true; reporter->passes = 0; reporter->failures = 0; reporter->exceptions = 0; reporter->breadcrumb = (void *)create_breadcrumb(); reporter->ipc = start_cgreen_messaging(45); context.reporter = reporter; return reporter; }
void last_name_pushed_is_current() { Breadcrumb *breadcrumb = create_breadcrumb(); push_breadcrumb(breadcrumb, "Hello"); assert_string_equal(get_current_from_breadcrumb(breadcrumb), "Hello"); destroy_breadcrumb(breadcrumb); }
void empty_breadcrumb_does_not_trigger_walker() { expect_never(mock_walker); Breadcrumb *breadcrumb = create_breadcrumb(); walk_breadcrumb(breadcrumb, &mock_walker, NULL); }
void can_destroy_empty_breadcrumb() { destroy_breadcrumb(create_breadcrumb()); }
void popping_last_name_leaves_breadcrumb_empty() { Breadcrumb *breadcrumb = create_breadcrumb(); push_breadcrumb(breadcrumb, "Hello"); pop_breadcrumb(breadcrumb); assert_equal(get_current_from_breadcrumb(breadcrumb), NULL); }
void empty_breadcrumb_has_null_as_current() { Breadcrumb *breadcrumb = create_breadcrumb(); assert_equal(get_current_from_breadcrumb(breadcrumb), NULL); }
void can_push_more_than_one_item() { Breadcrumb *breadcrumb = create_breadcrumb(); push_breadcrumb(breadcrumb, "Hello"); push_breadcrumb(breadcrumb, "Goodbye"); assert_string_equal(get_current_from_breadcrumb(breadcrumb), "Goodbye"); }