<commit_before>﻿namespace FunctionalHttp.Tests

open NUnit.Framework
open FsUnit

open FunctionalHttp

module ChallengeTests =
    [<Test>]
    let ``test parsing with base64 data`` () =
        let tests = [("Basic   dfjskdlfhjshflkjhfdslhd434543sdfsfsgdfdf=====", "dfjskdlfhjshflkjhfdslhd434543sdfsfsgdfdf=====") ]

        for (test, expected) in tests do
            match Parser.parse Challenge.Parser (test.AsInput()) with
            | Success (result, next) -> 
                match result.DataOrParameters with
                | Choice1Of2 data-> data |> should equal expected
                | _ -> failwith ("Parse failed for test: " + test)
            | _ -> failwith ("Parse failed for test: " + test)

    [<Test>]
    let  ``test parting with parameters`` () =
        let tests = [("Basic realm=\"foo\"", [("realm", "foo")]) ;
                     ("Basic realm=foo",     [("realm", "foo")]) ;
                     ("Basic realm = \"\\f\\o\\o\"", [("realm", "foo")])]


        for (test, expected) in tests do
            match Parser.parse Challenge.Parser (test.AsInput()) with
            | Success (result, next) -> 
                match result.DataOrParameters with
                | Choice2Of2 parameters-> parameters |> should equal (expected |> Map.ofSeq)
                | _ -> failwith ("Parse failed for test: " + test)
            | _ -> failwith ("Parse failed for test: " + test)
<commit_msg>More challenge tests.<commit_after>﻿namespace FunctionalHttp.Tests

open NUnit.Framework
open FsUnit

open FunctionalHttp

module ChallengeTests =
    [<Test>]
    let ``test parsing with base64 data`` () =
        let tests = [("Basic   dfjskdlfhjshflkjhfdslhd434543sdfsfsgdfdf=====", "dfjskdlfhjshflkjhfdslhd434543sdfsfsgdfdf=====") ]

        for (test, expected) in tests do
            match Parser.parse Challenge.Parser (test.AsInput()) with
            | Success (result, next) -> 
                match result.DataOrParameters with
                | Choice1Of2 data-> data |> should equal expected
                | _ -> failwith ("Parse failed for test: " + test)
            | _ -> failwith ("Parse failed for test: " + test)

    [<Test>]
    let  ``test parting with parameters`` () =
        let tests = [("Basic realm=\"foo\"",                                "Basic",   [("realm", "foo")]);
                     ("Basic realm=foo",                                    "Basic",   [("realm", "foo")]);
                     ("Basic , realm=\"foo\"",                              "Basic",   [("realm", "foo")]);
                     ("Basic realm = \"\\f\\o\\o\"",                        "Basic",   [("realm", "foo")]);
                     ("Basic realm = \"foo\"",                              "Basic",   [("realm", "foo")]);
                     ("Basic realm=\"\\\"foo\\\"\"",                        "Basic",   [("realm", "\"foo\"")]);
                     ("Basic realm=\"foo\", bar=\"xyz\",, a=b,,,c=d",       "Basic",   [("realm", "foo"); ("bar", "xyz"); ("a", "b"); ("c", "d")]);
                     ("Basic bar=\"xyz\", realm=\"foo\"",                   "Basic",   [("realm", "foo"); ("bar", "xyz")]);
                     ("Basic realm=\"foo-\u00E4\"",                         "Basic",   [("realm", "foo-\u00E4")]);
                     ("Basic realm=\"foo-\u00A4\"",                         "Basic",   [("realm", "foo-\u00A4")]);
                     ("Basic realm=\"=?ISO-8859-1?Q?foo-=E4?=\"",           "Basic",   [("realm", "=?ISO-8859-1?Q?foo-=E4?=")]);
                     ("Newauth realm=\"newauth\"",                          "Newauth", [("realm", "newauth")]);
                     ("Basic foo=\"realm=nottherealm\", realm=\"basic\"",   "Basic",   [("foo", "realm=nottherealm"); ("realm", "basic")]);
                     ("Basic nottherealm=\"nottherealm\", realm=\"basic\"", "Basic",   [("nottherealm", "nottherealm"); ("realm", "basic")]);]
                     
        for (test, expectedScheme, expectedParams) in tests do
            match Parser.parse Challenge.Parser (test.AsInput()) with
            | Success (result, next) -> 
                result.Scheme |> should equal expectedScheme
                match result.DataOrParameters with
                | Choice2Of2 parameters-> parameters |> should equal (expectedParams |> Map.ofSeq)
                | _ -> failwith ("Parse failed for test: " + test)
            | _ -> failwith ("Parse failed for test: " + test)

{'fraction_non_alphanumeric': 0.17706690696102725, 'fraction_numerical': 0.013516557783284524, 'mean_word_length': 1.7390499691548427, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6707944', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1244, 'n_words': 311}