Commit b2e537c1 authored by Julian Stirling's avatar Julian Stirling 🐧
Browse files

Add unit tests for new (not implemented) default parameter in libdict

parent 1a17d4b3
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -560,6 +560,38 @@ class TestKeyLookup4(BaseTestScadDict):
               '''
        self.run_scad(scad, has_errors=True)

class TestKeyLookup5(BaseTestScadDict):
    """
    Check openscad uses fallback when provided.
    """
    def test(self):
        '''Must be the only test in the class!'''
        scad = '''
               dict = [["a",3],
                       ["ab", 22],
                       ["raisin", 99],
                       ["great", 4]];
               val = key_lookup("foo", dict, default=21);
               assert(val==21);
               '''
        self.run_scad(scad, has_errors=False)

class TestKeyLookup6(BaseTestScadDict):
    """
    Check openscad uses ignores fallback if key exists.
    """
    def test(self):
        '''Must be the only test in the class!'''
        scad = '''
               dict = [["a",3],
                       ["ab", 22],
                       ["raisin", 99],
                       ["great", 4]];
               val = key_lookup("raisin", dict, default=21);
               assert(val==99);
               '''
        self.run_scad(scad, has_errors=False)

class TestReplace1(BaseTestScadDict):
    """
    Check that a value can be replaced and then read  and that other values are