MCPcopy Index your code
hub / github.com/cpplint/cpplint / testPreprocessor

Method testPreprocessor

cpplint_unittest.py:6902–6967  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

6900 assert len(self.nesting_state.stack) == 0
6901
6902 def testPreprocessor(self):
6903 assert len(self.nesting_state.pp_stack) == 0
6904 self.UpdateWithLines(["#if MACRO1"])
6905 assert len(self.nesting_state.pp_stack) == 1
6906 self.UpdateWithLines(["#endif"])
6907 assert len(self.nesting_state.pp_stack) == 0
6908
6909 self.UpdateWithLines(["#ifdef MACRO2"])
6910 assert len(self.nesting_state.pp_stack) == 1
6911 self.UpdateWithLines(["#else"])
6912 assert len(self.nesting_state.pp_stack) == 1
6913 self.UpdateWithLines(["#ifdef MACRO3"])
6914 assert len(self.nesting_state.pp_stack) == 2
6915 self.UpdateWithLines(["#elif MACRO4"])
6916 assert len(self.nesting_state.pp_stack) == 2
6917 self.UpdateWithLines(["#endif"])
6918 assert len(self.nesting_state.pp_stack) == 1
6919 self.UpdateWithLines(["#endif"])
6920 assert len(self.nesting_state.pp_stack) == 0
6921
6922 self.UpdateWithLines(
6923 [
6924 "#ifdef MACRO5",
6925 "class A {",
6926 "#elif MACRO6",
6927 "class B {",
6928 "#else",
6929 "class C {",
6930 "#endif",
6931 ]
6932 )
6933 assert len(self.nesting_state.pp_stack) == 0
6934 assert len(self.nesting_state.stack) == 1
6935 assert isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)
6936 assert self.nesting_state.stack[0].name == "A"
6937 self.UpdateWithLines(["};"])
6938 assert len(self.nesting_state.stack) == 0
6939
6940 self.UpdateWithLines(["class D", "#ifdef MACRO7"])
6941 assert len(self.nesting_state.pp_stack) == 1
6942 assert len(self.nesting_state.stack) == 1
6943 assert isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)
6944 assert self.nesting_state.stack[0].name == "D"
6945 assert not self.nesting_state.stack[0].is_derived
6946
6947 self.UpdateWithLines(["#elif MACRO8", ": public E"])
6948 assert len(self.nesting_state.stack) == 1
6949 assert self.nesting_state.stack[0].name == "D"
6950 assert self.nesting_state.stack[0].is_derived
6951 assert not self.nesting_state.stack[0].seen_open_brace
6952
6953 self.UpdateWithLines(["#else", "{"])
6954 assert len(self.nesting_state.stack) == 1
6955 assert self.nesting_state.stack[0].name == "D"
6956 assert not self.nesting_state.stack[0].is_derived
6957 assert self.nesting_state.stack[0].seen_open_brace
6958
6959 self.UpdateWithLines(["#endif"])

Callers

nothing calls this directly

Calls 1

UpdateWithLinesMethod · 0.95

Tested by

no test coverage detected