comparison system/test/TestEnv.h @ 1476:5afbac960a30 plugin-path-config

Environment var tests (beginnings of)
author Chris Cannam
date Thu, 07 Jun 2018 16:18:42 +0100
parents
children 8ff5505ad28d
comparison
equal deleted inserted replaced
1475:bd1a2cacd1e7 1476:5afbac960a30
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version. See the file
12 COPYING included with this distribution for more information.
13 */
14
15 #ifndef TEST_ENV_H
16 #define TEST_ENV_H
17
18 #include "../System.h"
19
20 #include <QObject>
21 #include <QtTest>
22 #include <QDir>
23
24 #include <iostream>
25
26 using namespace std;
27
28 const std::string utf8_name_sprkt = "\343\202\271\343\203\235\343\203\274\343\202\257\343\201\256\345\257\272\351\231\242";
29
30 class TestEnv : public QObject
31 {
32 Q_OBJECT
33
34 private slots:
35 void getAbsent()
36 {
37 string value = "blather";
38 bool rv = getEnvUtf8("nonexistent_environment_variable_I_sincerely_hope_including_a_missspellling_just_to_be_sure",
39 value);
40 QCOMPARE(rv, false);
41 QCOMPARE(value, "");
42 }
43
44 void roundTripAsciiAscii()
45 {
46 bool rv = false;
47 rv = putEnvUtf8("SV_CORE_TEST_SYSTEM_RT_A_A", "EXPECTED_VALUE");
48 QCOMPARE(rv, true);
49 string value;
50 rv = getEnvUtf8("SV_CORE_TEST_SYSTEM_RT_A_A", value);
51 QCOMPARE(rv, true);
52 QCOMPARE(value, "EXPECTED_VALUE");
53 }
54
55 void roundTripAsciiUtf8()
56 {
57 bool rv = false;
58 rv = putEnvUtf8("SV_CORE_TEST_SYSTEM_RT_A_U", utf8_name_sprkt);
59 QCOMPARE(rv, true);
60 string value;
61 rv = getEnvUtf8("SV_CORE_TEST_SYSTEM_RT_A_U", value);
62 QCOMPARE(rv, true);
63 QCOMPARE(value, utf8_name_sprkt);
64 }
65
66 void roundTripUtf8Ascii()
67 {
68 bool rv = false;
69 rv = putEnvUtf8("SV_CORE_TEST_SYSTEM_RT_\351\207\215\345\272\206_A", "EXPECTED_VALUE");
70 QCOMPARE(rv, true);
71 string value;
72 rv = getEnvUtf8("SV_CORE_TEST_SYSTEM_RT_\351\207\215\345\272\206_A", value);
73 QCOMPARE(rv, true);
74 QCOMPARE(value, "EXPECTED_VALUE");
75 }
76
77 void roundTripUtf8Utf8()
78 {
79 bool rv = false;
80 rv = putEnvUtf8("SV_CORE_TEST_SYSTEM_RT_\351\207\215\345\272\206_A", utf8_name_sprkt);
81 QCOMPARE(rv, true);
82 string value;
83 rv = getEnvUtf8("SV_CORE_TEST_SYSTEM_RT_\351\207\215\345\272\206_A", value);
84 QCOMPARE(rv, true);
85 QCOMPARE(value, utf8_name_sprkt);
86 }
87 };
88
89 #endif
90
91
92
93
94