Skip to content

Commit

Permalink
refactor: update schema to scheme in c api
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Sep 5, 2023
1 parent f4f225d commit cda9912
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/ada_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ada_string ada_get_pathname(ada_url result);
ada_string ada_get_search(ada_url result);
ada_string ada_get_protocol(ada_url result);
uint8_t ada_get_host_type(ada_url result);
uint8_t ada_get_schema_type(ada_url result);
uint8_t ada_get_scheme_type(ada_url result);

// url_aggregator setters
// if ada_is_valid(result)) is false, the setters have no effect
Expand Down
2 changes: 1 addition & 1 deletion src/ada_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ uint8_t ada_get_host_type(ada_url result) noexcept {
return r->host_type;
}

uint8_t ada_get_schema_type(ada_url result) noexcept {
uint8_t ada_get_scheme_type(ada_url result) noexcept {
ada::result<ada::url_aggregator>& r = get_instance(result);
if (!r) {
return 0;
Expand Down
16 changes: 8 additions & 8 deletions tests/ada_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,50 +210,50 @@ TEST(ada_c, ada_clear_search) {
SUCCEED();
}

TEST(ada_c, ada_get_schema_type) {
TEST(ada_c, ada_get_scheme_type) {
std::string_view input;
ada_url out;

input = "http://www.google.com";
out = ada_parse(input.data(), input.size());
ASSERT_TRUE(ada_is_valid(out));
ASSERT_EQ(ada_get_schema_type(out), 0);
ASSERT_EQ(ada_get_scheme_type(out), 0);

input = "notspecial://www.google.com";
ada_free(out);
out = ada_parse(input.data(), input.size());
ASSERT_TRUE(ada_is_valid(out));
ASSERT_EQ(ada_get_schema_type(out), 1);
ASSERT_EQ(ada_get_scheme_type(out), 1);

input = "https://www.google.com";
ada_free(out);
out = ada_parse(input.data(), input.size());
ASSERT_TRUE(ada_is_valid(out));
ASSERT_EQ(ada_get_schema_type(out), 2);
ASSERT_EQ(ada_get_scheme_type(out), 2);

input = "ws://www.google.com/ws";
ada_free(out);
out = ada_parse(input.data(), input.size());
ASSERT_TRUE(ada_is_valid(out));
ASSERT_EQ(ada_get_schema_type(out), 3);
ASSERT_EQ(ada_get_scheme_type(out), 3);

input = "ftp://www.google.com/file.txt";
ada_free(out);
out = ada_parse(input.data(), input.size());
ASSERT_TRUE(ada_is_valid(out));
ASSERT_EQ(ada_get_schema_type(out), 4);
ASSERT_EQ(ada_get_scheme_type(out), 4);

input = "wss://www.google.com/wss";
ada_free(out);
out = ada_parse(input.data(), input.size());
ASSERT_TRUE(ada_is_valid(out));
ASSERT_EQ(ada_get_schema_type(out), 5);
ASSERT_EQ(ada_get_scheme_type(out), 5);

input = "file:///foo/bar";
ada_free(out);
out = ada_parse(input.data(), input.size());
ASSERT_TRUE(ada_is_valid(out));
ASSERT_EQ(ada_get_schema_type(out), 6);
ASSERT_EQ(ada_get_scheme_type(out), 6);

ada_free(out);
SUCCEED();
Expand Down

0 comments on commit cda9912

Please sign in to comment.