2
// SyntaxHighlightingTests.cs
5
// Mike Krüger <mkrueger@novell.com>
7
// Copyright (c) 2009 Mike Krüger
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
using NUnit.Framework;
29
using Mono.TextEditor.Highlighting;
31
namespace Mono.TextEditor.Tests
34
public class SyntaxHighlightingTests
37
public void ValidateSyntaxModes ()
39
Assert.IsTrue (SyntaxModeService.ValidateAllSyntaxModes ());
41
static void TestOutput (string input,
42
string expectedMarkup)
44
Document doc = new Document ();
45
doc.SyntaxMode = SyntaxModeService.GetSyntaxMode ("text/x-csharp");
47
string markup = doc.SyntaxMode.GetMarkup (doc, TextEditorOptions.DefaultOptions, SyntaxModeService.GetColorStyle (null, "TangoLight"), 0, doc.Length, false);
48
Assert.AreEqual (expectedMarkup, markup, "expected:" + expectedMarkup + Environment.NewLine + "But got:" + markup);
52
public void TestSpans ()
54
TestOutput ("/* TestMe */",
55
"<span foreground=\"#4E9A06\">/* TestMe */</span>");
59
public void TestStringEscapes ()
61
TestOutput ("\"Escape:\\\" \"outtext",
62
"<span foreground=\"#75507B\">\"Escape:\\\" \"</span><span foreground=\"#000000\">outtext</span>");
66
public void TestVerbatimStringEscapes ()
68
TestOutput ("@\"Escape:\"\" \"outtext",
69
"<span foreground=\"#75507B\">@\"Escape:\"\" \"</span><span foreground=\"#000000\">outtext</span>");
73
public void TestHexDigit ()
75
TestOutput ("0x12345679AFFEuL",
76
"<span foreground=\"#75507B\">0x12345679AFFEuL</span>");
80
public void TestDoubleDigit ()
82
TestOutput ("123.45678e-09d",
83
"<span foreground=\"#75507B\">123.45678e-09d</span>");