OKlibrary  0.2.1.6
Visualisation.mac
Go to the documentation of this file.
```00001 /* Rui Wang, 31.10.2009 (Swansea) */
00002 /* Copyright 2009 Oliver Kullmann
00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
00004 it and/or modify it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation and included in this library; either version 3 of the
00006 License, or any later version. */
00007
00022 oklib_include("OKlib/ComputerAlgebra/TestSystem/Lisp/Asserts.mac")\$
00023 oklib_include("OKlib/ComputerAlgebra/Trees/Lisp/Visualisation.mac")\$
00024
00025 kill(f)\$
00026
00027 /* ******************************
00028    * Tree drawing *
00029    ******************************
00030 */
00031
00032 okltest_tdlrt2points(f) := (
00033   assert(f([[[0,0]]]) = [[0,0]]),
00034   assert(f([[[0,0]],[[[-1,-1]]],[[[1,-1]]]]) = [[0,0],[-1,-1],[1,-1]]),
00035   assert(f([[[0,0]],[[[-2,-1]],[[[-3,-2]]],[[[-1,-2]]]],[[[2,-1]]]]) = [[0,0],[-2,-1],[-3,-2],[-1,-2],[2,-1]]),
00036   assert(f([[[0,0]],[[[-2,-1]]],[[[2,-1]],[[[1,-2]]],[[[3,-2]]]]]) = [[0,0],[-2,-1],[2,-1],[1,-2],[3,-2]]),
00037   assert(f([[[0,0]],[[[-2,-1]],[[[-3,-2]]],[[[-1,-2]]]],[[[2,-1]],[[[1,-2]]],[[[3,-2]]]]]) = [[0,0],[-2,-1],[-3,-2],[-1,-2],[2,-1],[1,-2],[3,-2]]),
00038   assert(f([[[0,0]],[[[-1,-1]]]]) = [[0,0],[-1,-1]]),
00039   assert(f([[[0,0]],[[[-2,-1]],[[[-3,-2]]]],[[[2,-1]]]]) = [[0,0],[-2,-1],[-3,-2],[2,-1]]),
00040   assert(f([[[0,0]],[[[-2,-1]]],[[[2,-1]],[[[1,-2]]]]]) = [[0,0],[-2,-1],[2,-1],[1,-2]]),
00041   assert(f([[[0,0]],[[[-2,-1]],[[[-3,-2]]]],[[[2,-1]],[[[1,-2]]]]]) = [[0,0],[-2,-1],[-3,-2],[2,-1],[1,-2]]),
00042   true)\$
00043
00044 okltest_tdlrt2edges(f) := (
00045   assert(f([[[0,0]]]) = [[[0,0]]]),
00046   assert(f([[[0,0]],[[[-1,-1]]],[[[1,-1]]]]) = [[[0,0],[-1,-1]],[[0,0],[1,-1]]]),
00047   assert(f([[[0,0]],[[[-2,-1]],[[[-3,-2]]],[[[-1,-2]]]],[[[2,-1]]]]) = [[[0,0],[-2,-1]],[[-2,-1],[-3,-2]],[[-2,-1],[-1,-2]],[[0,0],[2,-1]]]),
00048   assert(f([[[0,0]],[[[-2,-1]]],[[[2,-1]],[[[1,-2]]],[[[3,-2]]]]]) = [[[0,0],[-2,-1]],[[0,0],[2,-1]],[[2,-1],[1,-2]],[[2,-1],[3,-2]]]),
00049   assert(f([[[0,0]],[[[-2,-1]],[[[-3,-2]]],[[[-1,-2]]]],[[[2,-1]],[[[1,-2]]],[[[3,-2]]]]]) = [[[0,0],[-2,-1]],[[-2,-1],[-3,-2]],[[-2,-1],[-1,-2]],[[0,0],[2,-1]],[[2,-1],[1,-2]],[[2,-1],[3,-2]]]),
00050   assert(f([[[0,0]],[[[-1,-1]]]]) = [[[0,0],[-1,-1]]]),
00051   assert(f([[[0,0]],[[[-2,-1]],[[[-3,-2]]]],[[[2,-1]]]]) = [[[0,0],[-2,-1]],[[-2,-1],[-3,-2]],[[0,0],[2,-1]]]),
00052   assert(f([[[0,0]],[[[-2,-1]]],[[[2,-1]],[[[1,-2]]]]]) = [[[0,0],[-2,-1]],[[0,0],[2,-1]],[[2,-1],[1,-2]]]),
00053   assert(f([[[0,0]],[[[-2,-1]],[[[-3,-2]]]],[[[2,-1]],[[[1,-2]]]]]) = [[[0,0],[-2,-1]],[[-2,-1],[-3,-2]],[[0,0],[2,-1]],[[2,-1],[1,-2]]]),
00054   true)\$
00055
00056 okltest_lrt2value(f) := (
00057   assert(f([[0]]) = [[0]]),
00058   assert(f([[0],[[1]],[[2]]]) = [[0],[1],[2]]),
00059   assert(f([[0],[[2],[[3]]],[[2],[[1]]]]) = [[0],[2],[3],[2],[1]]),
00060   assert(f([[0],[[1]],[[2],[[1]],[[3]]]]) = [[0],[1],[2],[1],[3]]),
00061   assert(f([[0],[[2],[[2]],[[1]]],[[2],[[1]],[[3]]]]) = [[0],[2],[2],[1],[2],[1],[3]]),
00062   assert(f([[0],[[1],[[3]]],[[2],[[1]]]]) = [[0],[1],[3],[2],[1]]),
00063   true)\$
00064
00065 okltest_dec2hex(f) := (
00066   assert(f(0) = "00"),
00067   assert(f(4) = "04"),
00068   assert(f(11) = "0B"),
00069   assert(f(16) = "10"),
00070   assert(f(254) = "FE"),
00071   true)\$
00072
00073 okltest_format_rgb(f) := (
00074   assert(f([0,0,1]) = "#000001"),
00075   assert(f([15,11,1]) = "#0F0B01"),
00076   assert(f([111,231,13]) = "#6FE70D"),
00077   assert(f([255,255,255]) = "#FFFFFF"),
00078   true)\$
00079
00080
```