forked from AsherGlick/Burrito
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First set of attribute tests. Contains one case of a value being copi…
…ed over and one case of a value being changed from zero to false.
- Loading branch information
Showing
5 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
xml_converter/test_cases/can_fade_tests/can_fade_is_false.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<OverlayData> | ||
<MarkerCategory Name="IsFalse"> | ||
</MarkerCategory> | ||
|
||
<POIs> | ||
<POI CanFade="false"/> | ||
</POIs> | ||
</OverlayData> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<OverlayData> | ||
<MarkerCategory Name="IsZero"> | ||
</MarkerCategory> | ||
|
||
<POIs> | ||
<POI CanFade="0" Type="IsZero"/> | ||
</POIs> | ||
</OverlayData> |
8 changes: 8 additions & 0 deletions
8
xml_converter/test_cases/test_output/can_fade_corrected_zero.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<OverlayData> | ||
<MarkerCategory Name="IsZero"> | ||
</MarkerCategory> | ||
|
||
<POIs> | ||
<POI CanFade="false" Type="IsZero"/> | ||
</POIs> | ||
</OverlayData> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<OverlayData> | ||
<MarkerCategory Name="IsFalse"> | ||
</MarkerCategory> | ||
|
||
<POIs> | ||
<POI CanFade="false"/> | ||
</POIs> | ||
</OverlayData> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include "../src/attribute/bool.hpp" | ||
#include "../src/packaging_xml.hpp" | ||
#include <gtest/gtest.h> | ||
#include <fstream> | ||
|
||
class BoolTest : public ::testing::Test { | ||
protected: | ||
void SetUp() override { | ||
} | ||
void TearDown() override { | ||
} | ||
}; | ||
|
||
bool compare_files(const std::string& file1_path, const std::string& file2_path) { | ||
std::ifstream file1(file1_path); | ||
std::ifstream file2(file2_path); | ||
|
||
if (!file1.is_open() || !file2.is_open()) { | ||
std::cerr << "Error: Could not open one or both of the files." << std::endl; | ||
return false; | ||
} | ||
|
||
char char1, char2; | ||
bool files_are_equal = true; | ||
|
||
while (true) { | ||
char1 = file1.get(); | ||
char2 = file2.get(); | ||
|
||
if (char1 != char2) { | ||
files_are_equal = false; | ||
break; | ||
} | ||
|
||
if (file1.eof() && file2.eof()) { | ||
break; // Reached the end of both files | ||
} | ||
|
||
// If one file reaches the end before the other, they are not equal | ||
if (file1.eof() || file2.eof()) { | ||
files_are_equal = false; | ||
break; | ||
} | ||
} | ||
|
||
file1.close(); | ||
file2.close(); | ||
|
||
return files_are_equal; | ||
} | ||
|
||
TEST_F(BoolTest, ValueIsFalse) { | ||
std::map<std::string, Category> marker_categories; | ||
std::vector<Parseable*> parsed_pois; | ||
std::string xml_input = "../test_cases/can_fade_tests/can_fade_is_false.xml"; | ||
std::string xml_output = "../test_cases/test_output/can_fade_is_false.xml"; | ||
parse_xml_file(xml_input, &marker_categories, &parsed_pois); | ||
write_xml_file(xml_output, &marker_categories, &parsed_pois); | ||
EXPECT_TRUE(compare_files(xml_input, xml_output)); | ||
} | ||
|
||
TEST_F(BoolTest, ValueIsZero) { | ||
std::map<std::string, Category> marker_categories; | ||
std::vector<Parseable*> parsed_pois; | ||
std::string xml_input = "../test_cases/can_fade_tests/can_fade_is_zero.xml"; | ||
std::string xml_output = "../test_cases/test_output/can_fade_corrected_zero.xml"; | ||
parse_xml_file(xml_input, &marker_categories, &parsed_pois); | ||
write_xml_file(xml_output, &marker_categories, &parsed_pois); | ||
EXPECT_FALSE(compare_files(xml_input, xml_output)); | ||
} |