<commit_before>﻿namespace AngleSharp.Core.Tests.Xhtml
{
    using AngleSharp.Xhtml;
    using NUnit.Framework;
    using System.IO;

    [TestFixture]
    public class AutoSelectMarkupFormatter
    {
        [Test]
        public void TestMetaTags()
        {
            var swResult = new StringWriter();
            var document = (@"<!DOCTYPE html PUBLIC "" -//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">
                <html xmlns=""http://www.w3.org/1999/xhtml"">
                    <head>
                        <title>test.html</title>
                        <meta http-equiv=""Content-Type"" content=""text/html;charset=utf-8"" />
                        <meta name=""viewport"" content=""width=device-width"" />
                    </head>
                    <body>...</body>
                </html>
                ").ToHtmlDocument();

            document.ToHtml(swResult, new AutoSelectedMarkupFormatter(document.Doctype));

            var result = swResult.ToString();
            var c = 0;
            var i = -1;

            while ((i = result.IndexOf("/>", i + 1)) >= 0)
            {
                c++;

                if (i >= result.Length)
                {
                    Assert.Fail("End of result xhtml reached but not found what we are looking for!");
                }
            }

            Assert.AreEqual(2, c);
            Assert.AreEqual(-1, result.IndexOf("meta>"));
        }
        
        [Test]
        public void TestImgTags()
        {
            var swResult = new StringWriter();
            var document = (@"<!DOCTYPE html PUBLIC "" -//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">
                <html xmlns=""http://www.w3.org/1999/xhtml"">
                    <head>
                        <title>test.html</title>
                    </head>
                    <body>
                        <div>Image label1</div>
                        <img src=""/images/test1.png"" alt=""My Image1""/>

                        <div>Image label2</div>
                        <img src=""/images/test2.png"" alt=""My Image2""/>
                    </body>
                </html>
                ").ToHtmlDocument();

            document.ToHtml(swResult, new AutoSelectedMarkupFormatter(document.Doctype));

            var result = swResult.ToString();
            var c = 0;
            var i = -1;

            while ((i = result.IndexOf("/>", i + 1)) >= 0)
            {
                c++;

                if (i >= result.Length)
                {
                    Assert.Fail("End of result xhtml reached but not found what we are looking for!");
                }
            }

            Assert.AreEqual(2, c);
            Assert.AreEqual(-1, result.IndexOf("img>"));
        }

        [Test]
        public void TestSomeComment()
        {
            var swResult = new StringWriter();
            var source = @"<html xmlns=""http://www.w3.org/1999/xhtml"">
<head></head>
<!-- Comment -->
<body></body>
</html>";
            var document = source.ToHtmlDocument();
            document.ToHtml(swResult, new AutoSelectedMarkupFormatter(document.Doctype));
            Assert.IsNotNull(swResult.ToString());
        }

        [Test]
        public void TestTrailingComment()
        {
            var swResult = new StringWriter();
            var source = @"<html xmlns=""http://www.w3.org/1999/xhtml"">
<head></head>
<body></body>
</html>
<!-- Comment -->";
            var document = source.ToHtmlDocument();
            document.ToHtml(swResult, new AutoSelectedMarkupFormatter(document.Doctype));
            Assert.IsNotNull(swResult.ToString());
        }
    }
}<commit_msg>Another test - problem already solved<commit_after>﻿namespace AngleSharp.Core.Tests.Xhtml
{
    using AngleSharp.Dom;
    using AngleSharp.Xhtml;
    using NUnit.Framework;
    using System.IO;
    using System.Linq;

    [TestFixture]
    public class AutoSelectMarkupFormatter
    {
        [Test]
        public void TestMetaTags()
        {
            var swResult = new StringWriter();
            var document = (@"<!DOCTYPE html PUBLIC "" -//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">
                <html xmlns=""http://www.w3.org/1999/xhtml"">
                    <head>
                        <title>test.html</title>
                        <meta http-equiv=""Content-Type"" content=""text/html;charset=utf-8"" />
                        <meta name=""viewport"" content=""width=device-width"" />
                    </head>
                    <body>...</body>
                </html>
                ").ToHtmlDocument();

            document.ToHtml(swResult, new AutoSelectedMarkupFormatter(document.Doctype));

            var result = swResult.ToString();
            var c = 0;
            var i = -1;

            while ((i = result.IndexOf("/>", i + 1)) >= 0)
            {
                c++;

                if (i >= result.Length)
                {
                    Assert.Fail("End of result xhtml reached but not found what we are looking for!");
                }
            }

            Assert.AreEqual(2, c);
            Assert.AreEqual(-1, result.IndexOf("meta>"));
        }
        
        [Test]
        public void TestImgTags()
        {
            var swResult = new StringWriter();
            var document = (@"<!DOCTYPE html PUBLIC "" -//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">
                <html xmlns=""http://www.w3.org/1999/xhtml"">
                    <head>
                        <title>test.html</title>
                    </head>
                    <body>
                        <div>Image label1</div>
                        <img src=""/images/test1.png"" alt=""My Image1""/>

                        <div>Image label2</div>
                        <img src=""/images/test2.png"" alt=""My Image2""/>
                    </body>
                </html>
                ").ToHtmlDocument();

            document.ToHtml(swResult, new AutoSelectedMarkupFormatter(document.Doctype));

            var result = swResult.ToString();
            var c = 0;
            var i = -1;

            while ((i = result.IndexOf("/>", i + 1)) >= 0)
            {
                c++;

                if (i >= result.Length)
                {
                    Assert.Fail("End of result xhtml reached but not found what we are looking for!");
                }
            }

            Assert.AreEqual(2, c);
            Assert.AreEqual(-1, result.IndexOf("img>"));
        }

        [Test]
        public void TestSomeComment()
        {
            var swResult = new StringWriter();
            var source = @"<html xmlns=""http://www.w3.org/1999/xhtml"">
<head></head>
<!-- Comment -->
<body></body>
</html>";
            var document = source.ToHtmlDocument();
            document.ToHtml(swResult, new AutoSelectedMarkupFormatter(document.Doctype));
            Assert.IsNotNull(swResult.ToString());
        }

        [Test]
        public void TestTrailingComment()
        {
            var swResult = new StringWriter();
            var source = @"<html xmlns=""http://www.w3.org/1999/xhtml"">
<head></head>
<body></body>
</html>
<!-- Comment -->";
            var document = source.ToHtmlDocument();
            document.ToHtml(swResult, new AutoSelectedMarkupFormatter(document.Doctype));
            Assert.IsNotNull(swResult.ToString());
        }

        [Test]
        public void TestRemovingComment()
        {
            var swResult = new StringWriter();
            var source = @"<html xmlns=""http://www.w3.org/1999/xhtml"">
<head></head>
<body></body>
</html>
<!-- Comment -->";
            var document = source.ToHtmlDocument();
            var comments = document.Descendents<IComment>().ToList();

            foreach (var comment in comments)
            {
                comment.Remove();
            }

            document.ToHtml(swResult, new AutoSelectedMarkupFormatter(document.Doctype));
            Assert.IsNotNull(swResult.ToString());
        }
    }
}
{'fraction_non_alphanumeric': 0.14357221340495666, 'fraction_numerical': 0.01306311805640337, 'mean_word_length': 1.431582071831404, 'pattern_counts': {'":': 0, '<': 91, '<?xml version=': 0, '>': 107, 'https://': 0, 'lorem ipsum': 0, 'www.': 13, 'xml': 9}, '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': '530237', 'n_tokens_mistral': 2386, 'n_tokens_neox': 2167, 'n_words': 454}