From 154bed1290f353992363116a3e684f76f314f69f Mon Sep 17 00:00:00 2001 From: "Hristos N. Triantafillou" Date: Sat, 29 Feb 2020 08:56:18 -0600 Subject: [PATCH] Tests --- obpmg_test.go | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 obpmg_test.go diff --git a/obpmg_test.go b/obpmg_test.go new file mode 100644 index 0000000..08a357c --- /dev/null +++ b/obpmg_test.go @@ -0,0 +1,64 @@ +// obpmg +// Copyright (C) 2020 Hristos N. Triantafillou +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +package main + +import ( + "encoding/xml" + "testing" +) + +func TestGetYamlData(t *testing.T) { + y, _ := getYamlData("sample.yml", false) + + if y[0].Label != "FTL: Faster Than Light" { + t.Errorf("Expected: %s, Got: %s", "FTL: Faster Than Light", y[0].Label) + } + + if y[1].Label != "MultiMC" { + t.Errorf("Expected: %s, Got: %s", "MultiMC", y[1].Label) + } + + if y[2].Label != "OpenMW" { + t.Errorf("Expected: %s, Got: %s", "OpenMW", y[2].Label) + } +} + +func TestToXml(t *testing.T) { + y, _ := getYamlData("sample.yml", false) + x := &xmlOpenboxPipeMenu{} + + for _, data := range y { + x.Items = append(x.Items, xmlItem{ + xml.Name{}, + xmlAction{ + xml.Name{}, + "Execute", + data.Exe, + }, + data.Label, + }, + ) + } + + xb := toXml(x) + + expected := "\n\n \n \n /home/hristos/games/FTL/FTL\n \n \n \n \n /usr/bin/MultiMC\n \n \n \n \n /opt/morrowind/openmw/bin/openmw-launcher\n \n \n\n" + + if string(xb) != expected { + t.Errorf("OH NOES\n") + } +} -- 2.45.2