Skip to content

Commit

Permalink
Add additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
eddie-planetnet committed Feb 25, 2025
1 parent c6567b8 commit 154152c
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions db/test/test_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ static void test_db_url(void)

i = 3;

DB_PARSE("mysql://user:pa/ss@host:3306/database?parameters");
DB_PARSE("mysql://user:pa/ss@host:6033/database?parameters");
ok(!strcmp(db->scheme, "mysql"), "parse_db_url: %d-schema: '%s'", i, db->scheme);
ok(!strcmp(db->username, "user"), "parse_db_url: %d-username: '%s'", i, db->username);
ok(!strcmp(db->password, "p/a,ss"), "parse_db_url: %d-password: '%s'", i, db->password);
ok(!strcmp(db->password, "pa/ss"), "parse_db_url: %d-password: '%s'", i, db->password);
ok(!strcmp(db->host, "host"), "parse_db_url: %d-host: '%s'", i, db->host);
ok((db->port == 6033), "parse_db_url: %d-port: '%d'", i, db->port);
ok((db->unix_socket == NULL), "parse_db_url: %d-unix_socket: '%s'", i, db->unix_socket);
Expand All @@ -76,10 +76,10 @@ static void test_db_url(void)

i = 4;

DB_PARSE("mysql://user@host:3306/database?parameters");
DB_PARSE("mysql://user@host:6033/database?parameters");
ok(!strcmp(db->scheme, "mysql"), "parse_db_url: %d-schema: '%s'", i, db->scheme);
ok(!strcmp(db->username, "user"), "parse_db_url: %d-username: '%s'", i, db->username);
ok(!strcmp(db->password, "p/a,ss"), "parse_db_url: %d-password: '%s'", i, db->password);
ok((db->password == NULL), "parse_db_url: %d-password: '%s'", i, db->password);
ok(!strcmp(db->host, "host"), "parse_db_url: %d-host: '%s'", i, db->host);
ok((db->port == 6033), "parse_db_url: %d-port: '%d'", i, db->port);
ok((db->unix_socket == NULL), "parse_db_url: %d-unix_socket: '%s'", i, db->unix_socket);
Expand All @@ -88,10 +88,10 @@ static void test_db_url(void)

i = 5;

DB_PARSE("mysql://user:p//a!,ss@host:3306/database?parameters");
DB_PARSE("mysql://user:p//a!,ss@host:6033/database?parameters");
ok(!strcmp(db->scheme, "mysql"), "parse_db_url: %d-schema: '%s'", i, db->scheme);
ok(!strcmp(db->username, "user"), "parse_db_url: %d-username: '%s'", i, db->username);
ok(!strcmp(db->password, "p/a,ss"), "parse_db_url: %d-password: '%s'", i, db->password);
ok(!strcmp(db->password, "p//a!,ss"), "parse_db_url: %d-password: '%s'", i, db->password);
ok(!strcmp(db->host, "host"), "parse_db_url: %d-host: '%s'", i, db->host);
ok((db->port == 6033), "parse_db_url: %d-port: '%d'", i, db->port);
ok((db->unix_socket == NULL), "parse_db_url: %d-unix_socket: '%s'", i, db->unix_socket);
Expand All @@ -100,13 +100,25 @@ static void test_db_url(void)

i = 6;

DB_PARSE("mysql://user:pa//ss@host:3306/database?parameters");
DB_PARSE("mysql://user:pa//ss@host:6033/database?parameters");
ok(!strcmp(db->scheme, "mysql"), "parse_db_url: %d-schema: '%s'", i, db->scheme);
ok(!strcmp(db->username, "user"), "parse_db_url: %d-username: '%s'", i, db->username);
ok(!strcmp(db->password, "p/a,ss"), "parse_db_url: %d-password: '%s'", i, db->password);
ok(!strcmp(db->password, "pa//ss"), "parse_db_url: %d-password: '%s'", i, db->password);
ok(!strcmp(db->host, "host"), "parse_db_url: %d-host: '%s'", i, db->host);
ok((db->port == 6033), "parse_db_url: %d-port: '%d'", i, db->port);
ok((db->unix_socket == NULL), "parse_db_url: %d-unix_socket: '%s'", i, db->unix_socket);
ok(!strcmp(db->database, "database"), "parse_db_url: %d-database: '%s'", i, db->database);
ok(!strcmp(db->parameters, "parameters"), "parse_db_url: %d-parameters: '%s'", i, db->parameters);
}

i = 7;

DB_PARSE("mysql://user:@host:6033/database?parameters");
ok(!strcmp(db->scheme, "mysql"), "parse_db_url: %d-schema: '%s'", i, db->scheme);
ok(!strcmp(db->username, "user"), "parse_db_url: %d-username: '%s'", i, db->username);
ok(!strcmp(db->password, ""), "parse_db_url: %d-password: '%s'", i, db->password);
ok(!strcmp(db->host, "host"), "parse_db_url: %d-host: '%s'", i, db->host);
ok((db->port == 6033), "parse_db_url: %d-port: '%d'", i, db->port);
ok((db->unix_socket == NULL), "parse_db_url: %d-unix_socket: '%s'", i, db->unix_socket);
ok(!strcmp(db->database, "database"), "parse_db_url: %d-database: '%s'", i, db->database);
ok(!strcmp(db->parameters, "parameters"), "parse_db_url: %d-parameters: '%s'", i, db->parameters);
}

0 comments on commit 154152c

Please sign in to comment.