~bratsche/ubuntu/maverick/monodevelop/disable-appmenu

« back to all changes in this revision

Viewing changes to tests/UnitTests/Mono.TextEditor.Tests/SyntaxHighlightingTests.cs

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ebner
  • Date: 2009-03-17 17:55:55 UTC
  • mfrom: (1.1.13 sid)
  • Revision ID: james.westby@ubuntu.com-20090317175555-2w5qbmu0l5maq6fq
Tags: 1.9.3+dfsg-1ubuntu1
* FFe for Monodevelop 2 granted by motu-release team :)
* Merge from Debian Unstable , remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
// SyntaxHighlightingTests.cs
 
3
//  
 
4
// Author:
 
5
//       Mike Krüger <mkrueger@novell.com>
 
6
// 
 
7
// Copyright (c) 2009 Mike Krüger
 
8
// 
 
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:
 
15
// 
 
16
// The above copyright notice and this permission notice shall be included in
 
17
// all copies or substantial portions of the Software.
 
18
// 
 
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
 
25
// THE SOFTWARE.
 
26
 
 
27
using System;
 
28
using NUnit.Framework;
 
29
using Mono.TextEditor.Highlighting;
 
30
 
 
31
namespace Mono.TextEditor.Tests
 
32
{
 
33
        [TestFixture()]
 
34
        public class SyntaxHighlightingTests
 
35
        {
 
36
                [Test]
 
37
                public void ValidateSyntaxModes ()
 
38
                {
 
39
                        Assert.IsTrue (SyntaxModeService.ValidateAllSyntaxModes ());
 
40
                }
 
41
                static void TestOutput (string input,
 
42
                                         string expectedMarkup)
 
43
                {
 
44
                        Document doc = new Document ();
 
45
                        doc.SyntaxMode = SyntaxModeService.GetSyntaxMode ("text/x-csharp");
 
46
                        doc.Text = input;
 
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);
 
49
                }
 
50
                
 
51
                [Test]
 
52
                public void TestSpans ()
 
53
                {
 
54
                        TestOutput ("/* TestMe */",
 
55
                                "<span foreground=\"#4E9A06\">/* TestMe */</span>");
 
56
                }
 
57
                
 
58
                [Test]
 
59
                public void TestStringEscapes ()
 
60
                {
 
61
                        TestOutput ("\"Escape:\\\" \"outtext",
 
62
                                "<span foreground=\"#75507B\">\"Escape:\\\" \"</span><span foreground=\"#000000\">outtext</span>");
 
63
                }
 
64
                
 
65
                [Test]
 
66
                public void TestVerbatimStringEscapes ()
 
67
                {
 
68
                        TestOutput ("@\"Escape:\"\" \"outtext",
 
69
                                "<span foreground=\"#75507B\">@\"Escape:\"\" \"</span><span foreground=\"#000000\">outtext</span>");
 
70
                }
 
71
                
 
72
                [Test]
 
73
                public void TestHexDigit ()
 
74
                {
 
75
                        TestOutput ("0x12345679AFFEuL",
 
76
                                "<span foreground=\"#75507B\">0x12345679AFFEuL</span>");
 
77
                }
 
78
                
 
79
                [Test]
 
80
                public void TestDoubleDigit ()
 
81
                {
 
82
                        TestOutput ("123.45678e-09d",
 
83
                                "<span foreground=\"#75507B\">123.45678e-09d</span>");
 
84
                }
 
85
        }
 
86
}