Skip to content

Commit

Permalink
Restructure test_data directory
Browse files Browse the repository at this point in the history
* Make it reflect an EE install/user directory split
* Add NWSync test data
  • Loading branch information
jd28 committed Apr 4, 2022
1 parent f172686 commit 99e78c5
Show file tree
Hide file tree
Showing 108 changed files with 153 additions and 164 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*.mod binary
*.tlk binary
*.zip binary
*.sqlite3

# Github
tests/test_data/** -linguist-detectable
tests/test_data/user/development/** -linguist-detectable
6 changes: 3 additions & 3 deletions tests/formats_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
TEST_CASE("Parse Bioware DDS", "[formats]")
{
std::filesystem::create_directory("tmp");
nw::Image dds{"test_data/bioRGBA.dds"};
nw::Image dds{"test_data/user/development/bioRGBA.dds"};
REQUIRE(dds.valid());
#ifndef _WIN32
CHECK(dds.write_to("tmp/bioRGBA.dds"));
Expand All @@ -20,7 +20,7 @@ TEST_CASE("Parse Bioware DDS", "[formats]")
TEST_CASE("Parse Standard DDS", "[formats]")
{
std::filesystem::create_directory("tmp");
nw::Image dds{"test_data/dxtRBG.dds"};
nw::Image dds{"test_data/user/development/dxtRBG.dds"};
REQUIRE(dds.valid());
#ifndef _WIN32
CHECK(dds.write_to("tmp/dxtRBG.dds"));
Expand All @@ -32,7 +32,7 @@ TEST_CASE("Parse Standard DDS", "[formats]")
TEST_CASE("Parse TGA", "[formats]")
{
std::filesystem::create_directory("tmp");
nw::Image tga{"test_data/qfpp_001_L.tga"};
nw::Image tga{"test_data/user/development/qfpp_001_L.tga"};
REQUIRE(tga.valid());
#ifndef _WIN32
CHECK(tga.write_to("tmp/qfpp_001_L.dds"));
Expand Down
2 changes: 1 addition & 1 deletion tests/formats_ini.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

TEST_CASE("Parse INI", "[formats]")
{
nw::Ini i{"test_data/nwnplayer.ini"};
nw::Ini i{"test_data/user/nwnplayer.ini"};
REQUIRE(i.valid());
int server_down_timer = 0;
REQUIRE(i.get_to("Server Options/ServerDownTimer", server_down_timer));
Expand Down
2 changes: 1 addition & 1 deletion tests/formats_nss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using namespace nw;

TEST_CASE("NWScript Parser", "[formats]")
{
Nss nss("test_data/test.nss");
Nss nss("test_data/user/development/test.nss");
auto prog = nss.parse();
NssAstPrinter p;
prog.accept(&p);
Expand Down
4 changes: 2 additions & 2 deletions tests/formats_twoda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

TEST_CASE("TwoDA Parse", "[formats]")
{
nw::TwoDA feat("test_data/feat.2da");
nw::TwoDA feat("test_data/user/development/feat.2da");
REQUIRE(feat.is_valid());
REQUIRE(feat.rows() == 1116);
REQUIRE(*feat.get<std::string_view>(4, 0) == "ArmProfMed");
REQUIRE(*feat.get<int32_t>(0, "FEAT") == 289);

nw::TwoDA empty("test_data/empty.2da");
nw::TwoDA empty("test_data/user/development/empty.2da");
REQUIRE(!empty.is_valid());

std::ofstream out{"tmp/feat_reform.2da", std::ios_base::binary};
Expand Down
31 changes: 12 additions & 19 deletions tests/i18n_tlk.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include <catch2/catch.hpp>

#include <nw/i18n/Tlk.hpp>
#include <nw/kernel/Kernel.hpp>
#include <nw/log.hpp>
#include <nw/util/game_install.hpp>

TEST_CASE("Tlk", "[formats]")
{
nw::Tlk t = nw::Tlk("test_data/dialog.tlk");
nw::Tlk t = nw::Tlk("test_data/root/data/dialog.tlk");
REQUIRE(t.valid());
REQUIRE(t.size() > 0);
REQUIRE(t.get(1000) == "Silence");
Expand All @@ -15,34 +15,27 @@ TEST_CASE("Tlk", "[formats]")

TEST_CASE("tlk: load languages")
{
nw::InstallInfo paths;
try {
paths = nw::probe_nwn_install();
} catch (...) {
}

if (std::filesystem::exists(paths.install)) {
nw::Tlk de{paths.install / "lang/de/data/dialog.tlk"};
REQUIRE(de.valid());
REQUIRE(de.get(10) == "Mönch");
de.save_as("tmp/dialog.tlk");
nw::Tlk t2 = nw::Tlk{"tmp/dialog.tlk"};
REQUIRE(t2.valid());
REQUIRE(de.get(10) == "Mönch");
}
auto install_path = nw::kernel::config().options().info.install;
nw::Tlk de{install_path / "lang/de/data/dialog.tlk"};
REQUIRE(de.valid());
REQUIRE(de.get(10) == "Mönch");
de.save_as("tmp/dialog.tlk");
nw::Tlk t2 = nw::Tlk{"tmp/dialog.tlk"};
REQUIRE(t2.valid());
REQUIRE(de.get(10) == "Mönch");
}

TEST_CASE("tlk: set", "[i18n]")
{
nw::Tlk t = nw::Tlk("test_data/dialog.tlk");
nw::Tlk t = nw::Tlk("test_data/root/data/dialog.tlk");
REQUIRE(t.valid());
t.set(1, "Hello World");
REQUIRE(t.get(1) == "Hello World");
}

TEST_CASE("tlk: save_as", "[i18n]")
{
nw::Tlk t = nw::Tlk("test_data/dialog.tlk");
nw::Tlk t = nw::Tlk("test_data/root/data/dialog.tlk");
REQUIRE(t.valid());
t.set(1, "Hello World");
t.save_as("tmp/dialog.tlk");
Expand Down
4 changes: 2 additions & 2 deletions tests/kernel_strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

TEST_CASE("strings manager", "[kernel]")
{
nw::kernel::strings().load_dialog_tlk("test_data/dialog.tlk");
nw::kernel::strings().load_custom_tlk("test_data/dialog.tlk");
nw::kernel::strings().load_dialog_tlk("test_data/root/data/dialog.tlk");
nw::kernel::strings().load_custom_tlk("test_data/root/data/dialog.tlk");

REQUIRE(nw::kernel::strings().get(1000) == "Silence");
REQUIRE(nw::kernel::strings().get(0x01001000) == "Stay here and don't move until I return.");
Expand Down
6 changes: 3 additions & 3 deletions tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ int main(int argc, char* argv[])
nw::init_logger(argc, argv);

nw::InstallInfo info{
"test_data/",
"test_data/",
"test_data/root/",
"test_data/user/",
nw::GameVersion::vEE};

nw::kernel::config().initialize({info, false, false});
nw::kernel::config().initialize({info});
nw::kernel::services().start();

Catch::Session session; // There must be exactly one instance
Expand Down
18 changes: 9 additions & 9 deletions tests/objects_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

TEST_CASE("area: from_gff", "[objects]")
{
nw::GffInputArchive are{"test_data/test_area.are"};
nw::GffInputArchive git{"test_data/test_area.git"};
nw::GffInputArchive gic{"test_data/test_area.gic"};
nw::GffInputArchive are{"test_data/user/development/test_area.are"};
nw::GffInputArchive git{"test_data/user/development/test_area.git"};
nw::GffInputArchive gic{"test_data/user/development/test_area.gic"};

nw::Area area{are.toplevel(), git.toplevel(), gic.toplevel()};
REQUIRE(area.tileset == "ttf02");
Expand All @@ -29,9 +29,9 @@ TEST_CASE("area: from_gff", "[objects]")

TEST_CASE("area: to_json", "[objects]")
{
nw::GffInputArchive are{"test_data/test_area.are"};
nw::GffInputArchive git{"test_data/test_area.git"};
nw::GffInputArchive gic{"test_data/test_area.gic"};
nw::GffInputArchive are{"test_data/user/development/test_area.are"};
nw::GffInputArchive git{"test_data/user/development/test_area.git"};
nw::GffInputArchive gic{"test_data/user/development/test_area.gic"};

nw::Area area{are.toplevel(), git.toplevel(), gic.toplevel()};

Expand All @@ -43,9 +43,9 @@ TEST_CASE("area: to_json", "[objects]")

TEST_CASE("area: json roundtrip", "[objects]")
{
nw::GffInputArchive are{"test_data/test_area.are"};
nw::GffInputArchive git{"test_data/test_area.git"};
nw::GffInputArchive gic{"test_data/test_area.gic"};
nw::GffInputArchive are{"test_data/user/development/test_area.are"};
nw::GffInputArchive git{"test_data/user/development/test_area.git"};
nw::GffInputArchive gic{"test_data/user/development/test_area.gic"};

nw::Area area{are.toplevel(), git.toplevel(), gic.toplevel()};

Expand Down
10 changes: 5 additions & 5 deletions tests/objects_creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

TEST_CASE("Loading nw_chicken", "[objects]")
{
nw::GffInputArchive g{"test_data/nw_chicken.utc"};
nw::GffInputArchive g{"test_data/user/development/nw_chicken.utc"};
nw::Creature c{g.toplevel(), nw::SerializationProfile::blueprint};
REQUIRE(c.common()->resref == "nw_chicken");
REQUIRE(c.stats.abilities[2] == 8);
Expand All @@ -20,7 +20,7 @@ TEST_CASE("Loading nw_chicken", "[objects]")

TEST_CASE("Loading test_creature", "[objects]")
{
nw::GffInputArchive g{"test_data/pl_agent_001.utc"};
nw::GffInputArchive g{"test_data/user/development/pl_agent_001.utc"};
nw::Creature c{g.toplevel(), nw::SerializationProfile::blueprint};
REQUIRE(c.common()->resref == "pl_agent_001");
REQUIRE(c.stats.abilities[2] == 16);
Expand All @@ -37,7 +37,7 @@ TEST_CASE("Loading test_creature", "[objects]")

TEST_CASE("creature: to_json", "[objects]")
{
nw::GffInputArchive g{"test_data/pl_agent_001.utc"};
nw::GffInputArchive g{"test_data/user/development/pl_agent_001.utc"};
nw::Creature c{g.toplevel(), nw::SerializationProfile::blueprint};

nlohmann::json j = c.to_json(nw::SerializationProfile::blueprint);
Expand All @@ -48,7 +48,7 @@ TEST_CASE("creature: to_json", "[objects]")

TEST_CASE("creature: json to and from", "[objects]")
{
nw::GffInputArchive g{"test_data/pl_agent_001.utc"};
nw::GffInputArchive g{"test_data/user/development/pl_agent_001.utc"};
nw::Creature c{g.toplevel(), nw::SerializationProfile::blueprint};
nlohmann::json j = c.to_json(nw::SerializationProfile::blueprint);
nw::Creature c2{j, nw::SerializationProfile::blueprint};
Expand All @@ -58,7 +58,7 @@ TEST_CASE("creature: json to and from", "[objects]")

TEST_CASE("creature: gff round trip", "[ojbects]")
{
nw::GffInputArchive g("test_data/pl_agent_001.utc");
nw::GffInputArchive g("test_data/user/development/pl_agent_001.utc");
REQUIRE(g.valid());

nw::Creature cre{g.toplevel(), nw::SerializationProfile::blueprint};
Expand Down
2 changes: 1 addition & 1 deletion tests/objects_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

TEST_CASE("Loading dialog", "[objects]")
{
nw::GffInputArchive g{"test_data/alue_ranger.dlg"};
nw::GffInputArchive g{"test_data/user/development/alue_ranger.dlg"};
nw::Dialog dlg{g.toplevel()};

REQUIRE(dlg.valid());
Expand Down
6 changes: 3 additions & 3 deletions tests/objects_door.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

TEST_CASE("door: from_gff", "[objects]")
{
nw::GffInputArchive g{"test_data/door_ttr_002.utd"};
nw::GffInputArchive g{"test_data/user/development/door_ttr_002.utd"};
REQUIRE(g.valid());
nw::Door d{g.toplevel(), nw::SerializationProfile::blueprint};
REQUIRE(d.valid());
Expand All @@ -22,7 +22,7 @@ TEST_CASE("door: from_gff", "[objects]")

TEST_CASE("door: to_json", "[objects]")
{
nw::GffInputArchive g{"test_data/door_ttr_002.utd"};
nw::GffInputArchive g{"test_data/user/development/door_ttr_002.utd"};
REQUIRE(g.valid());
nw::Door d{g.toplevel(), nw::SerializationProfile::blueprint};
REQUIRE(d.valid());
Expand All @@ -44,7 +44,7 @@ TEST_CASE("door: to_json", "[objects]")

TEST_CASE("door: gff round trip", "[ojbects]")
{
nw::GffInputArchive g("test_data/door_ttr_002.utd");
nw::GffInputArchive g("test_data/user/development/door_ttr_002.utd");
REQUIRE(g.valid());

nw::Door door{g.toplevel(), nw::SerializationProfile::blueprint};
Expand Down
8 changes: 4 additions & 4 deletions tests/objects_encounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

TEST_CASE("encounter: from_gff", "[objects]")
{
nw::GffInputArchive g{"test_data/boundelementallo.ute"};
nw::GffInputArchive g{"test_data/user/development/boundelementallo.ute"};
REQUIRE(g.valid());
nw::Encounter e{g.toplevel(), nw::SerializationProfile::blueprint};
REQUIRE(e.common()->resref == "boundelementallo");
Expand All @@ -21,7 +21,7 @@ TEST_CASE("encounter: from_gff", "[objects]")

TEST_CASE("encounter: to_json", "[objects]")
{
nw::GffInputArchive g{"test_data/boundelementallo.ute"};
nw::GffInputArchive g{"test_data/user/development/boundelementallo.ute"};
nw::Encounter e{g.toplevel(), nw::SerializationProfile::blueprint};

// REQUIRE(e.valid());
Expand All @@ -34,7 +34,7 @@ TEST_CASE("encounter: to_json", "[objects]")

TEST_CASE("encounter: json back and forth", "[objects]")
{
nw::GffInputArchive g{"test_data/boundelementallo.ute"};
nw::GffInputArchive g{"test_data/user/development/boundelementallo.ute"};
nw::Encounter e{g.toplevel(), nw::SerializationProfile::blueprint};
nlohmann::json j = e.to_json(nw::SerializationProfile::blueprint);
nw::Encounter e2{j, nw::SerializationProfile::blueprint};
Expand All @@ -44,7 +44,7 @@ TEST_CASE("encounter: json back and forth", "[objects]")

TEST_CASE("encount: gff round trip", "[ojbects]")
{
nw::GffInputArchive g("test_data/boundelementallo.ute");
nw::GffInputArchive g("test_data/user/development/boundelementallo.ute");
REQUIRE(g.valid());

nw::Encounter enc{g.toplevel(), nw::SerializationProfile::blueprint};
Expand Down
4 changes: 2 additions & 2 deletions tests/objects_faction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

TEST_CASE("faction: from_gff", "[objects]")
{
nw::GffInputArchive g{"test_data/Repute.fac"};
nw::GffInputArchive g{"test_data/user/development/Repute.fac"};
REQUIRE(g.valid());
nw::Faction f{g};
REQUIRE(f.factions.size() >= 4);
Expand All @@ -18,7 +18,7 @@ TEST_CASE("faction: from_gff", "[objects]")

TEST_CASE("faction: gff roundtrip", "[objects]")
{
nw::GffInputArchive g{"test_data/Repute.fac"};
nw::GffInputArchive g{"test_data/user/development/Repute.fac"};
REQUIRE(g.valid());
nw::Faction f{g};
nw::GffOutputArchive out = f.to_gff();
Expand Down
14 changes: 7 additions & 7 deletions tests/objects_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

TEST_CASE("item: load armor item", "[objects]")
{
nw::GffInputArchive g{"test_data/cloth028.uti"};
nw::GffInputArchive g{"test_data/user/development/cloth028.uti"};
nw::Item i{g.toplevel(), nw::SerializationProfile::blueprint};
REQUIRE(i.common()->resref == "cloth028");
REQUIRE(i.properties.size() > 0);
Expand All @@ -19,7 +19,7 @@ TEST_CASE("item: load armor item", "[objects]")

TEST_CASE("item: load layered item", "[objects]")
{
nw::GffInputArchive g{"test_data/wduersc004.uti"};
nw::GffInputArchive g{"test_data/user/development/wduersc004.uti"};
nw::Item i{g.toplevel(), nw::SerializationProfile::blueprint};
REQUIRE(i.common()->resref == "wduersc004");
REQUIRE(i.properties.size() > 0);
Expand All @@ -28,7 +28,7 @@ TEST_CASE("item: load layered item", "[objects]")

TEST_CASE("item: load simple item", "[objects]")
{
nw::GffInputArchive g{"test_data/pl_aleu_shuriken.uti"};
nw::GffInputArchive g{"test_data/user/development/pl_aleu_shuriken.uti"};
nw::Item i{g.toplevel(), nw::SerializationProfile::blueprint};
REQUIRE(i.common()->resref == "pl_aleu_shuriken");
REQUIRE(i.properties.size() > 0);
Expand All @@ -37,7 +37,7 @@ TEST_CASE("item: load simple item", "[objects]")

TEST_CASE("item: to_json", "[objects]")
{
nw::GffInputArchive g{"test_data/cloth028.uti"};
nw::GffInputArchive g{"test_data/user/development/cloth028.uti"};
nw::Item i{g.toplevel(), nw::SerializationProfile::blueprint};
REQUIRE(i.common()->resref == "cloth028");
REQUIRE(i.properties.size() > 0);
Expand All @@ -58,7 +58,7 @@ TEST_CASE("item: to_json", "[objects]")

TEST_CASE("item: json to and from", "[objects]")
{
nw::GffInputArchive g{"test_data/cloth028.uti"};
nw::GffInputArchive g{"test_data/user/development/cloth028.uti"};
nw::Item i{g.toplevel(), nw::SerializationProfile::blueprint};
nlohmann::json j = i.to_json(nw::SerializationProfile::blueprint);
nw::Item it2{j, nw::SerializationProfile::blueprint};
Expand All @@ -69,7 +69,7 @@ TEST_CASE("item: json to and from", "[objects]")

TEST_CASE("item: armor to_gff", "[objects]")
{
nw::GffInputArchive g{"test_data/cloth028.uti"};
nw::GffInputArchive g{"test_data/user/development/cloth028.uti"};
nw::Item i{g.toplevel(), nw::SerializationProfile::blueprint};
nw::GffOutputArchive oa{"UTI"};
REQUIRE(i.to_gff(oa.top, nw::SerializationProfile::blueprint));
Expand All @@ -84,7 +84,7 @@ TEST_CASE("item: armor to_gff", "[objects]")

TEST_CASE("item: gff round trip", "[ojbects]")
{
nw::GffInputArchive g("test_data/cloth028.uti");
nw::GffInputArchive g("test_data/user/development/cloth028.uti");
REQUIRE(g.valid());

nw::Item item{g.toplevel(), nw::SerializationProfile::blueprint};
Expand Down
Loading

0 comments on commit 99e78c5

Please sign in to comment.