Search in sources :

Example 11 with KeyValueTree

use of io.sloeber.core.txt.KeyValueTree in project arduino-eclipse-plugin by Sloeber.

the class TestTxtFile method getValuekey1.

@Test
public void getValuekey1() {
    KeyValueTree root = getDataSet1();
    String result = root.getValue("key2");
    String expectedResult = "value2";
    assertEquals("Wrong getvalue", expectedResult, result);
}
Also used : KeyValueTree(io.sloeber.core.txt.KeyValueTree) Test(org.junit.Test)

Example 12 with KeyValueTree

use of io.sloeber.core.txt.KeyValueTree in project arduino-eclipse-plugin by Sloeber.

the class TestTxtFile method dumpMatchesExpectationKey2.

@Test
public void dumpMatchesExpectationKey2() {
    KeyValueTree root = getDataSet1();
    KeyValueTree key1 = root.getChild("key2");
    String result = key1.dump();
    String expectedResult = "key2_1=value2_1\n";
    assertEquals("select key 2", expectedResult, result);
}
Also used : KeyValueTree(io.sloeber.core.txt.KeyValueTree) Test(org.junit.Test)

Example 13 with KeyValueTree

use of io.sloeber.core.txt.KeyValueTree in project arduino-eclipse-plugin by Sloeber.

the class TestTxtFile method getDataSet1.

private KeyValueTree getDataSet1() {
    KeyValueTree root = KeyValueTree.createTxtRoot();
    KeyValueTree key2 = root.addChild("key2", "value2");
    key2.addChild("key2_1", "value2_1");
    KeyValueTree key1 = root.addChild("key1");
    key1.addChild("key1_1", "value1_1");
    key1.addChild("key1_2", "value1_2");
    return root;
}
Also used : KeyValueTree(io.sloeber.core.txt.KeyValueTree)

Example 14 with KeyValueTree

use of io.sloeber.core.txt.KeyValueTree in project arduino-eclipse-plugin by Sloeber.

the class TestTxtFile method dumpMatchesExpectationFull2.

@Test
public void dumpMatchesExpectationFull2() {
    KeyValueTree root = getDataSet1();
    root.addValue("he.I.Can.Do.This", "not once");
    root.addValue("he.I.Can.Hit.This", "not twice");
    root.addValue("he.I.Can.hit.This", "not three times");
    root.addValue("Something.Completely.different", "but always");
    String result = root.dump();
    String expectedResult = "key2=value2\n" + "key2.key2_1=value2_1\n" + "key1.key1_1=value1_1\n" + "key1.key1_2=value1_2\n" + "he.I.Can.Do.This=not once\n" + "he.I.Can.Hit.This=not twice\n" + "he.I.Can.hit.This=not three times\n" + "Something.Completely.different=but always\n";
    assertEquals("creation", expectedResult, result);
}
Also used : KeyValueTree(io.sloeber.core.txt.KeyValueTree) Test(org.junit.Test)

Example 15 with KeyValueTree

use of io.sloeber.core.txt.KeyValueTree in project arduino-eclipse-plugin by Sloeber.

the class TestTxtFile method dumpMatchesExpectationKey3.

@Test
public void dumpMatchesExpectationKey3() {
    KeyValueTree root = getDataSet2();
    KeyValueTree keyHe = root.getChild("he");
    KeyValueTree keyI = keyHe.getChild("I");
    KeyValueTree keyCan = keyI.getChild("Can");
    String result = keyCan.dump();
    String expectedResult = "Do.This=not once\n" + "Hit.This=not twice\n" + "hit.This=not three times\n";
    assertEquals("select key 2", expectedResult, result);
}
Also used : KeyValueTree(io.sloeber.core.txt.KeyValueTree) Test(org.junit.Test)

Aggregations

KeyValueTree (io.sloeber.core.txt.KeyValueTree)15 Test (org.junit.Test)9 TxtFile (io.sloeber.core.txt.TxtFile)2 BoardTxtFile (io.sloeber.core.txt.BoardTxtFile)1 PlatformTxtFile (io.sloeber.core.txt.PlatformTxtFile)1 Programmers (io.sloeber.core.txt.Programmers)1 HashMap (java.util.HashMap)1 IFile (org.eclipse.core.resources.IFile)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1