blob: 84ce942bf69d02ff1c0a9fa80ece9ef2a99fc482 [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
bungeman60e0fee2015-08-26 05:15:46 -070011#include <stdlib.h>
12
tfarina35fbd012014-08-12 09:03:16 -070013// Friended proxy for SkRTConfRegistry::parse()
14template <typename T>
15bool test_rt_conf_parse(SkRTConfRegistry* reg, const char* key, T* value) {
16 return reg->parse(key, value);
17}
18
19static void portable_setenv(const char* key, const char* value) {
20#ifdef SK_BUILD_FOR_WIN32
21 _putenv_s(key, value);
22#else
23 setenv(key, value, 1);
commit-bot@chromium.orgc1bf2de2013-08-14 18:14:37 +000024#endif
25}
tfarina35fbd012014-08-12 09:03:16 -070026
27DEF_TEST(SkRTConfRegistry, reporter) {
28 SkRTConfRegistry reg;
29
30 portable_setenv("skia_nonexistent_item", "132");
31 int result = 0;
32 test_rt_conf_parse(&reg, "nonexistent.item", &result);
33 REPORTER_ASSERT(reporter, result == 132);
34}