Skip to content

Commit

Permalink
tests for getting missing regions
Browse files Browse the repository at this point in the history
  • Loading branch information
sargeantPig committed Jan 1, 2024
1 parent 8c1de25 commit 35f9219
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions RTWLibPlus/randomiser/randDS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public static string RandCitiesVoronoi(SMF smf, RandWrap rnd, DS ds = null, City
Vector2[] vp = Voronoi.GetVoronoiPoints(factions.Count, cm.Width, cm.Height, rnd);
List<string[]> gh = Voronoi.GetVoronoiGroups(cm.CityCoordinates, vp);

//gh.Shuffle(TWRand.rnd);
//factions.Shuffle(TWRand.rnd);
// gh.Shuffle(TWRand.rnd);
// factions.Shuffle(TWRand.rnd);
// function to get missing settlements and add them to the pool
for (int i = 0; i < factions.Count; i++)
{
Expand Down
35 changes: 35 additions & 0 deletions RTWLib_Tests/modifiers/Tests_drMod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace RTWLib_Tests.Modifiers;

using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RTWLibPlus.data;
using RTWLibPlus.dataWrappers;
using RTWLibPlus.helpers;
using RTWLibPlus.interfaces;
using RTWLibPlus.parsers;
using RTWLibPlus.parsers.objects;
using RTWLibPlus.Modifiers;

[TestClass]
public class TestsDR
{
private readonly DepthParse dp = new();
private readonly TWConfig config = TWConfig.LoadConfig(@"resources/remaster.json");

[TestMethod]
public void GetMissingRegions()
{
string[] dr = this.dp.ReadFile(RFH.CurrDirPath("resources", "descr_regions.txt"), false);
List<IBaseObj> smfParse = this.dp.Parse(dr, Creator.DRcreator, '\t');
DR parseddr = new(smfParse, this.config);
string[] ds = this.dp.ReadFile(RFH.CurrDirPath("resources", "descr_strat.txt"), false);
List<IBaseObj> dsParse = this.dp.Parse(ds, Creator.DScreator);
DS parsedds = new(dsParse, this.config);
List<IBaseObj> settlements = parsedds.GetItemsByIdent("settlement").DeepCopy();
List<string> missing = DRModifier.GetMissingRegionNames(settlements, parseddr);

int result = settlements.Count + missing.Count;
Assert.AreEqual(parseddr.Regions.Count, result);
}

}

0 comments on commit 35f9219

Please sign in to comment.