Skip to content

Commit

Permalink
This adds a test with a comma. (#32)
Browse files Browse the repository at this point in the history
* This adds a test with a comma.

* Formatting.

* Reformatting demo.cpp
  • Loading branch information
lemire authored Jul 21, 2023
1 parent 56337a7 commit 3a6c7b1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
19 changes: 10 additions & 9 deletions singleheader/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "ada_idna.h"

int main(int, char *[]) {
std::string input (
std::string input(
"\x2d\x2d\x5d\x2d\x2d\x2d\x2d\x01\x00\x00\x00\x00\x00\x00\x77\x6d\x2d\x77"
"\x77\x6d\x77\x2d\x77\x77\x77\x77\x77\x77\x73\x61\x61\x61\x61\x61\x61\x61"
"\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61"
Expand Down Expand Up @@ -10826,14 +10826,15 @@ int main(int, char *[]) {
"\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61"
"\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61"
"\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61"
"\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x77\x77\x73",194796)
;
std::u32string output;
bool x = ada::idna::punycode_to_utf32(input, output);
std::cout << x << std::endl;
std::cout << input.size() << std::endl;
std::cout << output.size()*sizeof(uint32_t) << std::endl;
"\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x77\x77"
"\x73",
194796);
std::u32string output;
bool x = ada::idna::punycode_to_utf32(input, output);
std::cout << x << std::endl;
std::cout << input.size() << std::endl;
std::cout << output.size() * sizeof(uint32_t) << std::endl;

//auto url = ada::idna::to_ascii("www.google.com");
// auto url = ada::idna::to_ascii("www.google.com");
return EXIT_SUCCESS;
}
10 changes: 10 additions & 0 deletions tests/to_ascii_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,17 @@ bool special_cases() {
return true;
}

bool comma_test() {
if (ada::idna::to_ascii("128.0,0.1").empty()) {
return false;
}
return true;
}

int main(int argc, char** argv) {
if (!comma_test()) {
return EXIT_FAILURE;
}
if (!special_cases()) {
return EXIT_FAILURE;
}
Expand Down

0 comments on commit 3a6c7b1

Please sign in to comment.