<commit_before>﻿using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using NUnit.Framework;

namespace MiniMVC.Tests {
    [TestFixture]
    public class XTests {
        [Test]
        public void FixEmptyScripts() {
            var script = X.E("script", X.A("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"));
            var n = script.FixEmptyElements();
            Console.WriteLine(n.ToString());
            StringAssert.DoesNotContain("/>", n.ToString());
            StringAssert.Contains("/>", script.ToString());
        }

        [Test]
        public void FixVoidElement() {
            var x = X.E("input", X.A("type", "text"), "bla");
            var n = x.FixEmptyElements();
            Console.WriteLine(n.ToString());
            StringAssert.DoesNotContain("/>", x.ToString());
            StringAssert.Contains("/>", n.ToString());
        }

        [Test]
        public void ApplyNamespace() {
            var x = X.E("html",
                        X.E("head",
                            X.E("title", "Page title")),
                        X.E("body",
                            X.E("p", X.A("class", "ptext"), "hello")));
            var xhtml = x.ApplyNamespace(X.XHTML_Namespace);
            Console.WriteLine(xhtml.ToString());
            Assert.True(Regex.Matches(xhtml.ToString(), "xmlns=\"http://www.w3.org/1999/xhtml\"").Count == 1);
        }

        [Test]
        public void XRawPreservesSpaces() {
            var n = X.Raw("  <a> hello world</a>");
            var x = X.E("span", n);
            Assert.AreEqual("<span>  <a> hello world</a></span>", x.ToString());
        }

        [Test]
        public void WriteToStream() {
            var ms = new MemoryStream();
            var n = X.E("a", X.Raw("  <img src='something'/>"));
            n.WriteToStream(ms);
            ms.Position = 0;
            var s = Encoding.UTF8.GetString(ms.ToArray());
            Assert.AreEqual("﻿<a>  <img src=\"something\" /></a>", s);
        }

        [Test]
        public void Trim() {<commit_msg>Remove extraneous character<commit_after>﻿using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using NUnit.Framework;

namespace MiniMVC.Tests {
    [TestFixture]
    public class XTests {
        [Test]
        public void FixEmptyScripts() {
            var script = X.E("script", X.A("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"));
            var n = script.FixEmptyElements();
            Console.WriteLine(n.ToString());
            StringAssert.DoesNotContain("/>", n.ToString());
            StringAssert.Contains("/>", script.ToString());
        }

        [Test]
        public void FixVoidElement() {
            var x = X.E("input", X.A("type", "text"), "bla");
            var n = x.FixEmptyElements();
            Console.WriteLine(n.ToString());
            StringAssert.DoesNotContain("/>", x.ToString());
            StringAssert.Contains("/>", n.ToString());
        }

        [Test]
        public void ApplyNamespace() {
            var x = X.E("html",
                        X.E("head",
                            X.E("title", "Page title")),
                        X.E("body",
                            X.E("p", X.A("class", "ptext"), "hello")));
            var xhtml = x.ApplyNamespace(X.XHTML_Namespace);
            Console.WriteLine(xhtml.ToString());
            Assert.True(Regex.Matches(xhtml.ToString(), "xmlns=\"http://www.w3.org/1999/xhtml\"").Count == 1);
        }

        [Test]
        public void XRawPreservesSpaces() {
            var n = X.Raw("  <a> hello world</a>");
            var x = X.E("span", n);
            Assert.AreEqual("<span>  <a> hello world</a></span>", x.ToString());
        }

        [Test]
        public void WriteToStream() {
            var ms = new MemoryStream();
            var n = X.E("a", X.Raw("  <img src='something'/>"));
            n.WriteToStream(ms);
            ms.Position = 0;
            var s = Encoding.UTF8.GetString(ms.ToArray());
            Assert.AreEqual("<a>  <img src=\"something\" /></a>", s);
        }

        [Test]
        public void Trim() {
{'fraction_non_alphanumeric': 0.17093816129790737, 'fraction_numerical': 0.005172819186456619, 'mean_word_length': 1.767729342875732, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5594283', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1237, 'n_words': 250}