def testNonIncludesLinesAfterIncludesTerminates(self): begin, end = add_header.FindIncludes([ '#include "moo.h"', '#ifndef COW_MESSAGES_H_', '#define COW_MESSAGE_H_' ]) self.assertEqual(begin, 0) self.assertEqual(end, 1)
def testCommentsBetweenIncludes(self): begin, end = add_header.FindIncludes([ '#include <utility>', '// TODO: Add goat support.', '#include "moo.h"' ]) self.assertEqual(begin, 0) self.assertEqual(end, 3)
def testCommentsNotIncluded(self): begin, end = add_header.FindIncludes([ '// Cow module.', '#include <utility>', '// For cow speech synthesis.', '#include "moo.h"', '// TODO: Add Linux audio support.' ]) self.assertEqual(begin, 1) self.assertEqual(end, 4)
def testNonIncludesLinesBeforeIncludesIgnored(self): begin, end = add_header.FindIncludes( ['#ifndef COW_H_', '#define COW_H_', '#include "moo.h"']) self.assertEqual(begin, 2) self.assertEqual(end, 3)
def testEmptyLinesNotIncluded(self): begin, end = add_header.FindIncludes( ['', '#include <utility>', '', '#include "moo.h"', '']) self.assertEqual(begin, 1) self.assertEqual(end, 4)
def testNewlinesBetweenIncludes(self): begin, end = add_header.FindIncludes( ['#include <utility>', '', '#include "moo.h"']) self.assertEqual(begin, 0) self.assertEqual(end, 3)
def testIncludeWithInlineComment(self): begin, end = add_header.FindIncludes( ['#include "moo.h" // TODO: Add more sounds.']) self.assertEqual(begin, 0) self.assertEqual(end, 1)
def testOneInclude(self): begin, end = add_header.FindIncludes(['#include <algorithm>']) self.assertEqual(begin, 0) self.assertEqual(end, 1)
def testNoIncludes(self): begin, end = add_header.FindIncludes(['a']) self.assertEqual(begin, -1) self.assertEqual(end, -1)
def testEmpty(self): begin, end = add_header.FindIncludes([]) self.assertEqual(begin, -1) self.assertEqual(end, -1)