示例#1
0
def test_o2g2o():
    _input = '''
#pragma once

int main() {
  return 0;
}
'''
    guard = 'MATCH_H'
    output = g2o.replace_guard(o2g.replace_pragma_once(_input, guard), guard)
    assert_multi_line_equal(_input, output)
示例#2
0
def test_o2g2o():
    _input = '''
#pragma once

int main() {
  return 0;
}
'''
    guard = 'MATCH_H'
    output = g2o.replace_guard(o2g.replace_pragma_once(_input, guard), guard)
    assert_multi_line_equal(_input, output)
示例#3
0
def test_unknown_pattern_requires_content_between_guard_start_and_end():
    _input = '''
#ifndef ONE
#define ONE 1
#endif

int main() {
  return 0;
}
'''
    o = o2g.replace_guard(_input, None)
    assert_equal(None, o)
示例#4
0
def test_g2o2g():
    _input = '''
#ifndef MATCH_H
#define MATCH_H

int main() {
  return 0;
}
#endif
'''
    guard = 'MATCH_H'
    output = o2g.replace_pragma_once(g2o.replace_guard(_input, guard), guard)
    assert_multi_line_equal(_input, output)
示例#5
0
def test_g2o2g():
    _input = '''
#ifndef MATCH_H
#define MATCH_H

int main() {
  return 0;
}
#endif
'''
    guard = 'MATCH_H'
    output = o2g.replace_pragma_once(g2o.replace_guard(_input, guard), guard)
    assert_multi_line_equal(_input, output)
示例#6
0
def test_no_newline_at_eof():
    _input = '''
#ifndef MATCH_H
#define MATCH_H

int main() {
  return 0;
}
#endif'''
    expected = '''
#pragma once

int main() {
  return 0;
}
'''
    o = o2g.replace_guard(_input, 'MATCH_H')
    assert_multi_line_equal(expected, o)
示例#7
0
def test_with_comment_unknown_guard():
    _input = '''
#ifndef MATCH_H
#define MATCH_H

int main() {
  return 0;
}
#endif /* MATCH_H */
'''
    expected = '''
#pragma once

int main() {
  return 0;
}
'''
    o = o2g.replace_guard(_input, None)
    assert_multi_line_equal(expected, o)
示例#8
0
def test_known_pattern_does_not_require_content_between_guard_start_and_end():
    _input = '''
#ifndef ONE
#define ONE 1
#endif

int main() {
  return 0;
}
'''
    expected = '''
#pragma once

int main() {
  return 0;
}
'''
    o = o2g.replace_guard(_input, 'ONE')
    assert_multi_line_equal(expected, o)
示例#9
0
def test_strip_trailing_whitespace():
    _input = '''
#ifndef MATCH_H
#define MATCH_H

int main() {
  return 0;
}

#endif /* MATCH_H */
'''
    expected = '''
#pragma once

int main() {
  return 0;
}
'''
    o = o2g.replace_guard(_input, None, strip=True)
    assert_multi_line_equal(expected, o)