GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cppcheck/test/teststandards.cpp at main · cppcheck-opensource/cppcheck

Expand file tree

/

teststandards.cpp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
144 lines (123 loc) · 5.29 KB
/

teststandards.cpp

Copy path

File metadata and controls

144 lines (123 loc) · 5.29 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2024 Cppcheck team.
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "fixture.h"
#include "standards.h"
class TestStandards : public TestFixture {
public:
TestStandards() : TestFixture("TestStandards") {}
private:
void run() override {
TEST_CASE(set);
TEST_CASE(setCPPAlias);
TEST_CASE(setCAlias);
TEST_CASE(getC);
TEST_CASE(getCPP);
TEST_CASE(setStd);
}
void set() const {
Standards stds;
ASSERT_EQUALS_ENUM(Standards::CLatest, stds.c);
ASSERT_EQUALS("", stds.stdValueC);
ASSERT_EQUALS_ENUM(Standards::CPPLatest, stds.cpp);
ASSERT_EQUALS("", stds.stdValueCPP);
ASSERT_EQUALS(true, stds.setC("c99"));
ASSERT_EQUALS_ENUM(Standards::C99, stds.c);
ASSERT_EQUALS("c99", stds.stdValueC);
ASSERT_EQUALS_ENUM(Standards::CPPLatest, stds.cpp);
ASSERT_EQUALS("", stds.stdValueCPP);
ASSERT_EQUALS(true, stds.setC("c11"));
ASSERT_EQUALS_ENUM(Standards::C11, stds.c);
ASSERT_EQUALS("c11", stds.stdValueC);
ASSERT_EQUALS_ENUM(Standards::CPPLatest, stds.cpp);
ASSERT_EQUALS("", stds.stdValueCPP);
ASSERT_EQUALS(true, stds.setCPP("c++11"));
ASSERT_EQUALS_ENUM(Standards::C11, stds.c);
ASSERT_EQUALS("c11", stds.stdValueC);
ASSERT_EQUALS_ENUM(Standards::CPP11, stds.cpp);
ASSERT_EQUALS("c++11", stds.stdValueCPP);
ASSERT_EQUALS(true, stds.setCPP("c++23"));
ASSERT_EQUALS_ENUM(Standards::C11, stds.c);
ASSERT_EQUALS("c11", stds.stdValueC);
ASSERT_EQUALS_ENUM(Standards::CPP23, stds.cpp);
ASSERT_EQUALS("c++23", stds.stdValueCPP);
ASSERT_EQUALS(false, stds.setC("c77"));
ASSERT_EQUALS_ENUM(Standards::C11, stds.c);
ASSERT_EQUALS("c11", stds.stdValueC);
ASSERT_EQUALS_ENUM(Standards::CPP23, stds.cpp);
ASSERT_EQUALS("c++23", stds.stdValueCPP);
ASSERT_EQUALS(false, stds.setCPP("c+77"));
ASSERT_EQUALS_ENUM(Standards::C11, stds.c);
ASSERT_EQUALS("c11", stds.stdValueC);
ASSERT_EQUALS_ENUM(Standards::CPP23, stds.cpp);
ASSERT_EQUALS("c++23", stds.stdValueCPP);
ASSERT_EQUALS(false, stds.setC("C23"));
ASSERT_EQUALS_ENUM(Standards::C11, stds.c);
ASSERT_EQUALS("c11", stds.stdValueC);
ASSERT_EQUALS_ENUM(Standards::CPP23, stds.cpp);
ASSERT_EQUALS("c++23", stds.stdValueCPP);
ASSERT_EQUALS(false, stds.setCPP("C++11"));
ASSERT_EQUALS_ENUM(Standards::C11, stds.c);
ASSERT_EQUALS("c11", stds.stdValueC);
ASSERT_EQUALS_ENUM(Standards::CPP23, stds.cpp);
ASSERT_EQUALS("c++23", stds.stdValueCPP);
}
void setCPPAlias() const {
Standards stds;
ASSERT_EQUALS(true, stds.setCPP("gnu++11"));
ASSERT_EQUALS_ENUM(Standards::CLatest, stds.c);
ASSERT_EQUALS("", stds.stdValueC);
ASSERT_EQUALS_ENUM(Standards::CPP11, stds.cpp);
ASSERT_EQUALS("gnu++11", stds.stdValueCPP);
}
void setCAlias() const {
Standards stds;
ASSERT_EQUALS(true, stds.setC("gnu17"));
ASSERT_EQUALS_ENUM(Standards::C17, stds.c);
ASSERT_EQUALS("gnu17", stds.stdValueC);
ASSERT_EQUALS_ENUM(Standards::CPPLatest, stds.cpp);
ASSERT_EQUALS("", stds.stdValueCPP);
}
void getC() const {
ASSERT_EQUALS_ENUM(Standards::C99, Standards::getC("c99"));
ASSERT_EQUALS_ENUM(Standards::C11, Standards::getC("c11"));
ASSERT_EQUALS_ENUM(Standards::C17, Standards::getC("gnu17"));
ASSERT_EQUALS_ENUM(Standards::C11, Standards::getC("iso9899:2011"));
ASSERT_EQUALS_ENUM(Standards::CLatest, Standards::getC(""));
ASSERT_EQUALS_ENUM(Standards::CLatest, Standards::getC("c77"));
ASSERT_EQUALS_ENUM(Standards::CLatest, Standards::getC("C99"));
}
void getCPP() const {
ASSERT_EQUALS_ENUM(Standards::CPP11, Standards::getCPP("c++11"));
ASSERT_EQUALS_ENUM(Standards::CPP23, Standards::getCPP("c++23"));
ASSERT_EQUALS_ENUM(Standards::CPP23, Standards::getCPP("gnu++23"));
ASSERT_EQUALS_ENUM(Standards::CPPLatest, Standards::getCPP(""));
ASSERT_EQUALS_ENUM(Standards::CPPLatest, Standards::getCPP("c++77"));
ASSERT_EQUALS_ENUM(Standards::CPPLatest, Standards::getCPP("C++11"));
}
void setStd() const {
Standards stds;
ASSERT(stds.setStd("c11"));
ASSERT(stds.setStd("c++11"));
ASSERT(stds.setStd("gnu11"));
ASSERT(stds.setStd("gnu++17"));
ASSERT(stds.setStd("iso9899:2011"));
ASSERT(!stds.setStd("C++11"));
ASSERT(!stds.setStd("Gnu++11"));
}
};
REGISTER_TEST(TestStandards)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.