From 205105fffc13c7535edb5286d02241c8f73c1169 Mon Sep 17 00:00:00 2001
From: Alec Thomas <alec@swapoff.org>
Date: Thu, 8 Feb 2018 12:24:27 +1100
Subject: [PATCH] Fixed newlines at end of C++ files.

Fixes #104.
---
 lexers/cpp.go                |  1 +
 lexers/testdata/cpp.actual   |  3 +++
 lexers/testdata/cpp.expected | 37 ++++++++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+)
 create mode 100644 lexers/testdata/cpp.actual
 create mode 100644 lexers/testdata/cpp.expected

diff --git a/lexers/cpp.go b/lexers/cpp.go
index 18bf409..90fd373 100644
--- a/lexers/cpp.go
+++ b/lexers/cpp.go
@@ -11,6 +11,7 @@ var CPP = Register(MustNewLexer(
 		Aliases:   []string{"cpp", "c++"},
 		Filenames: []string{"*.cpp", "*.hpp", "*.c++", "*.h++", "*.cc", "*.hh", "*.cxx", "*.hxx", "*.C", "*.H", "*.cp", "*.CPP"},
 		MimeTypes: []string{"text/x-c++hdr", "text/x-c++src"},
+		EnsureNL:  true,
 	},
 	Rules{
 		"statements": {
diff --git a/lexers/testdata/cpp.actual b/lexers/testdata/cpp.actual
new file mode 100644
index 0000000..f037957
--- /dev/null
+++ b/lexers/testdata/cpp.actual
@@ -0,0 +1,3 @@
+template <typename T>
+void func(const std::string &s, const T &t) {
+} // Do interesting things.
\ No newline at end of file
diff --git a/lexers/testdata/cpp.expected b/lexers/testdata/cpp.expected
new file mode 100644
index 0000000..81724d1
--- /dev/null
+++ b/lexers/testdata/cpp.expected
@@ -0,0 +1,37 @@
+[
+  {"type":"Keyword","value":"template"},
+  {"type":"Text","value":" "},
+  {"type":"Operator","value":"\u003c"},
+  {"type":"Keyword","value":"typename"},
+  {"type":"Text","value":" "},
+  {"type":"Name","value":"T"},
+  {"type":"Operator","value":"\u003e"},
+  {"type":"Text","value":"\n"},
+  {"type":"KeywordType","value":"void"},
+  {"type":"Text","value":" "},
+  {"type":"Name","value":"func"},
+  {"type":"Punctuation","value":"("},
+  {"type":"Keyword","value":"const"},
+  {"type":"Text","value":" "},
+  {"type":"Name","value":"std"},
+  {"type":"Operator","value":"::"},
+  {"type":"Name","value":"string"},
+  {"type":"Text","value":" "},
+  {"type":"Operator","value":"\u0026"},
+  {"type":"Name","value":"s"},
+  {"type":"Punctuation","value":","},
+  {"type":"Text","value":" "},
+  {"type":"Keyword","value":"const"},
+  {"type":"Text","value":" "},
+  {"type":"Name","value":"T"},
+  {"type":"Text","value":" "},
+  {"type":"Operator","value":"\u0026"},
+  {"type":"Name","value":"t"},
+  {"type":"Punctuation","value":")"},
+  {"type":"Text","value":" "},
+  {"type":"Punctuation","value":"{"},
+  {"type":"Text","value":"\n"},
+  {"type":"Punctuation","value":"}"},
+  {"type":"Text","value":" "},
+  {"type":"CommentSingle","value":"// Do interesting things.\n"}
+]