More tests, and does clang++ work on travis yet?!

This commit is contained in:
Tim Warren 2015-06-19 16:37:24 -04:00
parent 91e8f40a70
commit 081690492e
6 changed files with 55 additions and 8 deletions

View File

@ -162,8 +162,7 @@ tests: $(TESTS) json_wrapper $(BASE_LIB) $(WIDGET_LIB)
run-tests: tests
./tests/runner -s
./tests/runner -r compact
./tests/runner
clean:
rm -f *.res

View File

@ -23,12 +23,22 @@ ThemeConfig::~ThemeConfig() {}
* Set the current theme
*
* @param string theme_name
* @return void
* @return bool
*/
void ThemeConfig::SetTheme(string theme_name)
bool ThemeConfig::SetTheme(string theme_name)
{
JsonValue theme_list = this->GetRoot();
this->current_theme = theme_list.get(theme_name, JsonValue());
JsonValue selected_theme = theme_list.get(theme_name, JsonValue());
if (selected_theme.isNull()) return FALSE;
if (selected_theme.isObject())
{
this->current_theme = selected_theme;
return TRUE;
}
return FALSE;
}
/**
@ -77,6 +87,6 @@ wxColor ThemeConfig::GetThemeColor(string type, string key)
}
else
{
return wxColor("black");
return wxColor("BLACK");
}
}

View File

@ -12,7 +12,7 @@ class ThemeConfig : TyroConfig {
public:
ThemeConfig();
~ThemeConfig();
void SetTheme(string theme_name);
bool SetTheme(string theme_name);
JsonValue GetTheme();
JsonValue GetThemeValue(string type, string key);
wxColor GetThemeColor(string type, string key);

View File

@ -41,16 +41,25 @@ TEST_CASE("Language Config Library")
SECTION("GetCurrentLangName()")
{
config->SetLang("cpp");
REQUIRE("C / C++" == config->GetCurrentLangName());
}
SECTION("GetLexerMap()")
{
JsonValue lexer_map = config->GetLexerMap("none");
REQUIRE(lexer_map.isNull());
lexer_map = config->GetLexerMap("cpp");
REQUIRE(lexer_map.isArray());
}
SECTION("GetKeywordList()")
{
JsonValue keyword_list = config->GetKeywordList("none");
REQUIRE(keyword_list.isNull());
keyword_list = config->GetKeywordList("cpp");
REQUIRE(keyword_list.isArray());
}
}

28
tests/ThemeConfigTest.cpp Normal file
View File

@ -0,0 +1,28 @@
#include "catch.hpp"
#include "../src/settings/ThemeConfig.h"
TEST_CASE("Theme Config Library")
{
ThemeConfig *config = new ThemeConfig();
SECTION("GetTheme()")
{
JsonValue theme = config->GetTheme();
REQUIRE(theme.isObject());
}
SECTION("SetTheme()")
{
REQUIRE_FALSE(config->SetTheme("foobar"));
REQUIRE(config->SetTheme("Solarized"));
}
SECTION("GetThemeColor()")
{
REQUIRE(config->SetTheme("Solarized"));
// Bad color
wxColor theme_color = config->GetThemeColor("foo", "bar");
REQUIRE(wxColor("BLACK") == theme_color);
}
}

View File

@ -62,6 +62,7 @@
#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
#include <stdlib>
#include <sstream>
#include <stdexcept>
#include <algorithm>