mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-30 09:00:04 +00:00 
			
		
		
		
	Updating settings test for palette settings, adding streams test
This commit is contained in:
		
							parent
							
								
									b241703b40
								
							
						
					
					
						commit
						803a25e884
					
				
					 4 changed files with 123 additions and 3 deletions
				
			
		|  | @ -1 +1 @@ | |||
| Subproject commit f52ed2862e07b849e826ee5964e415ef73d21bb6 | ||||
| Subproject commit dd31c5857e2747e8ff5e0628aaf038f3eb45c2bb | ||||
|  | @ -25,19 +25,22 @@ void VerifyDefaults() | |||
| { | ||||
|    std::shared_ptr<settings::GeneralSettings> defaultGeneralSettings = | ||||
|       settings::GeneralSettings::Create(); | ||||
|    std::shared_ptr<settings::PaletteSettings> defaultPaletteSettings = | ||||
|       settings::PaletteSettings::Create(); | ||||
| 
 | ||||
|    EXPECT_EQ(*defaultGeneralSettings, *SettingsManager::general_settings()); | ||||
|    EXPECT_EQ(*defaultPaletteSettings, *SettingsManager::palette_settings()); | ||||
| } | ||||
| 
 | ||||
| void CompareFiles(const std::string& file1, const std::string& file2) | ||||
| { | ||||
|    std::ifstream     ifs1 {file1}; | ||||
|    std::stringstream buffer1; | ||||
|    buffer1 << buffer1.rdbuf(); | ||||
|    buffer1 << ifs1.rdbuf(); | ||||
| 
 | ||||
|    std::ifstream     ifs2 {file2}; | ||||
|    std::stringstream buffer2; | ||||
|    buffer2 << buffer2.rdbuf(); | ||||
|    buffer2 << ifs2.rdbuf(); | ||||
| 
 | ||||
|    EXPECT_EQ(buffer1.str(), buffer2.str()); | ||||
| } | ||||
|  |  | |||
							
								
								
									
										116
									
								
								test/source/scwx/util/streams.test.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										116
									
								
								test/source/scwx/util/streams.test.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,116 @@ | |||
| #include <scwx/util/streams.hpp> | ||||
| 
 | ||||
| #include <gtest/gtest.h> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace util | ||||
| { | ||||
| 
 | ||||
| void VerifyTokens(const std::vector<std::string>& tokens) | ||||
| { | ||||
|    ASSERT_EQ(tokens.size(), 4); | ||||
|    EXPECT_EQ(tokens[0], "One"); | ||||
|    EXPECT_EQ(tokens[1], "Two"); | ||||
|    EXPECT_EQ(tokens[2], "Three"); | ||||
|    EXPECT_EQ(tokens[3], ""); | ||||
| } | ||||
| 
 | ||||
| TEST(StreamsTest, CRNoEnd) | ||||
| { | ||||
|    std::stringstream        ss {"One\rTwo\rThree"}; | ||||
|    std::vector<std::string> tokens; | ||||
|    std::string              t; | ||||
| 
 | ||||
|    while (scwx::util::getline(ss, t)) | ||||
|    { | ||||
|       tokens.push_back(t); | ||||
|    } | ||||
| 
 | ||||
|    EXPECT_EQ(ss.eof(), true); | ||||
| 
 | ||||
|    VerifyTokens(tokens); | ||||
| } | ||||
| 
 | ||||
| TEST(StreamsTest, CRWithEnd) | ||||
| { | ||||
|    std::stringstream        ss {"One\rTwo\rThree\r"}; | ||||
|    std::vector<std::string> tokens; | ||||
|    std::string              t; | ||||
| 
 | ||||
|    while (scwx::util::getline(ss, t)) | ||||
|    { | ||||
|       tokens.push_back(t); | ||||
|    } | ||||
| 
 | ||||
|    EXPECT_EQ(ss.eof(), true); | ||||
| 
 | ||||
|    VerifyTokens(tokens); | ||||
| } | ||||
| 
 | ||||
| TEST(StreamsTest, CRLFNoEnd) | ||||
| { | ||||
|    std::stringstream        ss {"One\r\nTwo\r\nThree"}; | ||||
|    std::vector<std::string> tokens; | ||||
|    std::string              t; | ||||
| 
 | ||||
|    while (scwx::util::getline(ss, t)) | ||||
|    { | ||||
|       tokens.push_back(t); | ||||
|    } | ||||
| 
 | ||||
|    EXPECT_EQ(ss.eof(), true); | ||||
| 
 | ||||
|    VerifyTokens(tokens); | ||||
| } | ||||
| 
 | ||||
| TEST(StreamsTest, CRLFWithEnd) | ||||
| { | ||||
|    std::stringstream        ss {"One\r\nTwo\r\nThree\r\n"}; | ||||
|    std::vector<std::string> tokens; | ||||
|    std::string              t; | ||||
| 
 | ||||
|    while (scwx::util::getline(ss, t)) | ||||
|    { | ||||
|       tokens.push_back(t); | ||||
|    } | ||||
| 
 | ||||
|    EXPECT_EQ(ss.eof(), true); | ||||
| 
 | ||||
|    VerifyTokens(tokens); | ||||
| } | ||||
| 
 | ||||
| TEST(StreamsTest, LFNoEnd) | ||||
| { | ||||
|    std::stringstream        ss {"One\nTwo\nThree"}; | ||||
|    std::vector<std::string> tokens; | ||||
|    std::string              t; | ||||
| 
 | ||||
|    while (scwx::util::getline(ss, t)) | ||||
|    { | ||||
|       tokens.push_back(t); | ||||
|    } | ||||
| 
 | ||||
|    EXPECT_EQ(ss.eof(), true); | ||||
| 
 | ||||
|    VerifyTokens(tokens); | ||||
| } | ||||
| 
 | ||||
| TEST(StreamsTest, LFWithEnd) | ||||
| { | ||||
|    std::stringstream        ss {"One\nTwo\nThree\n"}; | ||||
|    std::vector<std::string> tokens; | ||||
|    std::string              t; | ||||
| 
 | ||||
|    while (scwx::util::getline(ss, t)) | ||||
|    { | ||||
|       tokens.push_back(t); | ||||
|    } | ||||
| 
 | ||||
|    EXPECT_EQ(ss.eof(), true); | ||||
| 
 | ||||
|    VerifyTokens(tokens); | ||||
| } | ||||
| 
 | ||||
| } // namespace util
 | ||||
| } // namespace scwx
 | ||||
|  | @ -11,6 +11,7 @@ set(SRC_MAIN source/scwx/wxtest.cpp) | |||
| set(SRC_COMMON_TESTS source/scwx/common/color_table.test.cpp) | ||||
| set(SRC_QT_MANAGER_TESTS source/scwx/qt/manager/settings_manager.test.cpp) | ||||
| set(SRC_UTIL_TESTS source/scwx/util/rangebuf.test.cpp | ||||
|                    source/scwx/util/streams.test.cpp | ||||
|                    source/scwx/util/vectorbuf.test.cpp) | ||||
| set(SRC_WSR88D_TESTS source/scwx/wsr88d/ar2v_file.test.cpp) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat