blob: 59fb3e9142c81f8b1692738d1fdacac6bdda77ed [file] [log] [blame]
commit-bot@chromium.orgc1bf2de2013-08-14 18:14:37 +00001/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
tfarina@chromium.orge4fafb12013-12-12 21:11:12 +00008#include "SkRTConf.h"
tfarina@chromium.org8f6884a2014-01-24 20:56:26 +00009#include "Test.h"
commit-bot@chromium.orgc1bf2de2013-08-14 18:14:37 +000010
tfarina35fbd012014-08-12 09:03:16 -070011// Friended proxy for SkRTConfRegistry::parse()
12template <typename T>
13bool test_rt_conf_parse(SkRTConfRegistry* reg, const char* key, T* value) {
14 return reg->parse(key, value);
15}
16
17static void portable_setenv(const char* key, const char* value) {
18#ifdef SK_BUILD_FOR_WIN32
19 _putenv_s(key, value);
20#else
21 setenv(key, value, 1);
commit-bot@chromium.orgc1bf2de2013-08-14 18:14:37 +000022#endif
23}
tfarina35fbd012014-08-12 09:03:16 -070024
25DEF_TEST(SkRTConfRegistry, reporter) {
26 SkRTConfRegistry reg;
27
28 portable_setenv("skia_nonexistent_item", "132");
29 int result = 0;
30 test_rt_conf_parse(&reg, "nonexistent.item", &result);
31 REPORTER_ASSERT(reporter, result == 132);
32}