Skip to content

Commit

Permalink
Add test case for the empty proxy bypass list configured
Browse files Browse the repository at this point in the history
Simplify other config test cases with using predicate assertions instead of
expectations.
  • Loading branch information
sergio-nsk committed Feb 3, 2023
1 parent a241149 commit 6451d51
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions test/test_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,30 @@
TEST(config, override_auto_config_url) {
proxy_config_set_auto_config_url_override("http://127.0.0.1:8000/wpad.dat");
char *auto_config_url = proxy_config_get_auto_config_url();
EXPECT_NE(auto_config_url, nullptr);
if (auto_config_url) {
EXPECT_STREQ(auto_config_url, "http://127.0.0.1:8000/wpad.dat");
free(auto_config_url);
}
ASSERT_NE(auto_config_url, nullptr);
EXPECT_STREQ(auto_config_url, "http://127.0.0.1:8000/wpad.dat");
free(auto_config_url);
}

TEST(config, override_proxy) {
proxy_config_set_proxy_override("http://127.0.0.1:8000/");
char *proxy = proxy_config_get_proxy("http");
EXPECT_NE(proxy, nullptr);
if (proxy) {
EXPECT_STREQ(proxy, "http://127.0.0.1:8000/");
free(proxy);
}
ASSERT_NE(proxy, nullptr);
EXPECT_STREQ(proxy, "http://127.0.0.1:8000/");
free(proxy);
}

TEST(config, override_bypass_list) {
proxy_config_set_bypass_list_override("<local>");
char *bypass_list = proxy_config_get_bypass_list();
EXPECT_NE(bypass_list, nullptr);
if (bypass_list) {
EXPECT_STREQ(bypass_list, "<local>");
free(bypass_list);
}
ASSERT_NE(bypass_list, nullptr);
EXPECT_STREQ(bypass_list, "<local>");
free(bypass_list);
}

TEST(config, override_bypass_list_with_empt_list) {
proxy_config_set_bypass_list_override("");
char *bypass_list = proxy_config_get_bypass_list();
EXPECT_EQ(bypass_list, nullptr);
free(bypass_list); // In case the condition above is not met
}

0 comments on commit 6451d51

Please sign in to comment.