From 34e30c0bd48590ee42a47d9d831f2f99120be24a Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Wed, 20 Jul 2022 04:02:44 +0200 Subject: [PATCH] test/java_string: replace tabs with spaces, fix how tiny_utf8::string is being instantiated --- src/test/java_string.cpp | 75 +++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/src/test/java_string.cpp b/src/test/java_string.cpp index 563fab7..5e7cef5 100644 --- a/src/test/java_string.cpp +++ b/src/test/java_string.cpp @@ -23,48 +23,61 @@ int main(){ + // metadata for things in resources/unicode_data/ + // normal_utf-8: 116 bytes, 85 characters ?? + // java-style_unicode: 119 bytes, 85 characters ?? + std::cout << "################################################################################" << std::endl; std::cout << "Java String Tests" << std::endl; std::cout << "################################################################################" << std::endl; - std::streampos javaSize; - char* javaData; - std::ifstream javaFile("./resources/unicode_data/java-style_unicode", std::ios::in | std::ios::binary | std::ios::ate); - if(javaFile.is_open()){ - javaSize = javaFile.tellg(); - javaData = new char[javaSize]; - javaFile.seekg(0, std::ios::beg); - javaFile.read(javaData, javaSize); - javaFile.close(); - } + char* nextChar = new char; - tiny_utf8::string importString = JavaCompat::importJavaFormatToString((uint8_t*) javaData); + std::streampos javaSize; + std::string javaStdString; + const char* javaFilePath = "./resources/unicode_data/java-style_unicode"; + std::ifstream javaFile(javaFilePath, std::ios::in | std::ios::binary | std::ios::ate); + if(javaFile.is_open()){ + javaSize = javaFile.tellg(); + javaFile.seekg(0, std::ios::beg); - std::streampos normalSize; - char* normalData; - std::ifstream normalFile("./resources/unicode_data/normal_utf-8", std::ios::in | std::ios::binary | std::ios::ate); - if(normalFile.is_open()){ - normalSize = normalFile.tellg(); - normalData = new char[normalSize]; - normalFile.seekg(0, std::ios::beg); - normalFile.read(normalData, normalSize); - normalFile.close(); - } + for (int i=0; i normalDataVector = std::vector(); - for(int i=0; i(javaStdString.data())); - std::cout << normalString.size() << std::endl; - std::cout << importString.size() << std::endl; + std::streampos normalSize; + std::string normalStdString; + const char* normalFilePath = "./resources/unicode_data/normal_utf-8"; + std::ifstream normalFile(normalFilePath, std::ios::in | std::ios::binary | std::ios::ate); + if(normalFile.is_open()){ + normalSize = normalFile.tellg(); + normalFile.seekg(0, std::ios::beg); - ASSERT(normalString == importString); + for (int i=0; i