text:
// Warning! This file is autogenerated.
#include <boost/text/bidirectional.hpp>

#include "bidi_tests.hpp"

#include <gtest/gtest.h>

#include <algorithm>

TEST(bidi_character, bidi_character_061_000)
{

    {
        // line 42701
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x0061, 0x005B, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42702
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42703
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42704
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42705
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42706
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x0061, 0x005B, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42707
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x0061, 0x005B, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 2, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 3, 4, 5, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42708
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x0061, 0x005B, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42709
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x0061, 0x005B, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42710
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_001)
{

    {
        // line 42711
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42712
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42713
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42714
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42715
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42718
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42719
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42720
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42721
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42722
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x0061, 0x005B, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_002)
{

    {
        // line 42723
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x0061, 0x005B, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42724
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42725
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42726
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x005B, 0x0061, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42727
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x005B, 0x0061, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42728
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x0061, 0x05D1, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42729
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x0061, 0x05D1, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42730
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x0061, 0x005B, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42731
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x0061, 0x005B, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42732
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x0061, 0x005B, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_003)
{

    {
        // line 42733
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x0061, 0x005B, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42734
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x0061, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42735
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x0061, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42736
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x0061, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42737
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x0061, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42738
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x0061, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42739
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x0061, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42740
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x0061, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42741
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x0061, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42742
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x0061, 0x05D1, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_004)
{

    {
        // line 42743
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x0061, 0x05D1, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42744
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x0061, 0x005B, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42745
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x0061, 0x005B, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42746
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x0061, 0x005B, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42747
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x0061, 0x005B, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42748
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x0061, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42749
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x0061, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42750
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x0061, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42751
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x0061, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42752
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x0061, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_005)
{

    {
        // line 42753
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x0061, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42754
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x0061, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42755
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x0061, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42756
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x0061, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42757
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x0061, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42758
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x0061, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42759
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x0061, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42762
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x2681, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42763
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x2681, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42764
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x005B, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_006)
{

    {
        // line 42765
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x005B, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42766
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42767
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42768
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x005B, 0x05D1, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42769
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x005B, 0x05D1, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42770
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42771
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42772
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x2681, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42773
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x2681, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42774
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x005B, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_007)
{

    {
        // line 42775
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x005B, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42776
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x005B, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42777
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x005B, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42778
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x05D1, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42779
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x05D1, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42780
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x05D1, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42781
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x05D1, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42782
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x05D1, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42783
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x05D1, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42784
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x05D1, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_008)
{

    {
        // line 42785
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x05D1, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42786
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x2681, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42787
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x2681, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42788
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x005B, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42789
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x005B, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42790
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x005B, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42791
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x005B, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42792
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x05D1, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 4, 3, 2, 1, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42793
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x05D1, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42794
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x05D1, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 4, 3, 2, 1, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_009)
{

    {
        // line 42795
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x05D1, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42796
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x05D1, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 4, 3, 2, 1, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42797
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x05D1, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42798
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x05D1, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 4, 3, 2, 1, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42799
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x05D1, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42800
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x05D1, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 4, 3, 2, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42801
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x05D1, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42802
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x05D1, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 4, 3, 2, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42803
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x05D1, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42806
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_010)
{

    {
        // line 42807
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42808
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42809
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42810
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x005B, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42811
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x005B, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42812
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42813
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42814
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x005B, 0x05D1, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42815
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x005B, 0x05D1, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42816
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x0061, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_011)
{

    {
        // line 42817
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x0061, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42818
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x005B, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42819
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x005B, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42820
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x005B, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42821
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x005B, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42822
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x05D1, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42823
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x05D1, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42824
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x05D1, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42825
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x05D1, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42826
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x05D1, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_012)
{

    {
        // line 42827
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x05D1, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42828
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x05D1, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42829
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x05D1, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42830
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x0061, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42831
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x0061, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42832
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x005B, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42833
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x005B, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42834
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x005B, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42835
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x005B, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42836
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x05D1, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 4, 3, 2, 1, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_013)
{

    {
        // line 42837
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x05D1, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42838
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x05D1, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 4, 3, 2, 1, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42839
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x05D1, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42840
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x05D1, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 4, 3, 2, 1, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42841
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x05D1, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42842
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x05D1, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 4, 3, 2, 1, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42843
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x05D1, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42844
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x05D1, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 4, 3, 2, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42845
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x05D1, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42846
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x05D1, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 4, 3, 2, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_014)
{

    {
        // line 42847
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x05D1, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42850
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42851
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42852
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x005B, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42853
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x05D1, 0x005B, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42854
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x005B, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42855
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x005B, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42856
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x005B, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42857
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x005B, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42858
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x005B, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_015)
{

    {
        // line 42859
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x05D1, 0x005B, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42860
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42861
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x005B, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42862
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42863
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x2680, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42864
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x005B, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 5, 4, 3, 2, 1, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42865
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x005B, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42866
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x005B, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42867
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x05D1, 0x005B, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42868
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 1, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 4, 3, 2, 1, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_016)
{

    {
        // line 42869
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x005B, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42870
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 1, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 4, 3, 2, 1, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42871
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x2680, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42872
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 1, 1, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 4, 3, 2, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42873
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x2680, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42876
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x005B, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42877
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x005B, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42878
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x005B, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42879
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x005B, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42880
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_017)
{

    {
        // line 42881
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42882
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42883
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42884
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42885
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42886
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42887
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42888
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42889
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42890
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_018)
{

    {
        // line 42891
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42892
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42893
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42896
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x0062, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42897
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x0062, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 2, 3, 4, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42898
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x005B, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42899
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x005B, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 2, 3, 4, 5, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42900
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x005B, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42901
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x005B, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42902
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x2680, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_019)
{

    {
        // line 42903
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x2680, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 2, 3, 4, 5, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42904
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x2680, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42905
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x2680, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42906
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x2680, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42907
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x2680, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42908
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x2680, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42909
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x2680, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 2, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 3, 4, 5, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42910
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x2680, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42911
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x2680, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42912
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x2680, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_020)
{

    {
        // line 42913
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x2680, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42914
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x0062, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42915
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x0062, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 2, 3, 4, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42916
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42917
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 2, 3, 4, 5, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42918
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42919
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42920
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42921
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 2, 3, 4, 5, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42922
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_021)
{

    {
        // line 42923
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42924
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x2680, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42925
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x2680, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42926
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42927
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 2, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 3, 4, 5, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42928
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42929
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42930
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x2680, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42931
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x2680, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42932
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_022)
{

    {
        // line 42933
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 2, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 3, 4, 5, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42934
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42935
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42936
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x2680, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42937
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x2680, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42940
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x05D1, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42941
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x05D1, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42942
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x005B, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42943
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x005B, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42944
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x005B, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_023)
{

    {
        // line 42945
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x2680, 0x005B, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42946
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x2680, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42947
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x2680, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42948
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x2680, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42949
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x2680, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42950
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42951
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42952
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x2680, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42953
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x2680, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42954
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x2680, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_024)
{

    {
        // line 42955
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x2680, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42956
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42957
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42958
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x05D1, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42959
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x05D1, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42960
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42961
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42962
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42963
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42964
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_025)
{

    {
        // line 42965
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42966
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42967
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42968
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42969
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42970
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42971
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42972
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42973
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42974
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_026)
{

    {
        // line 42975
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42976
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42977
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42978
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42979
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42980
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42981
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42984
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42985
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 2, 3, 4, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42986
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_027)
{

    {
        // line 42987
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 2, 3, 4, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42988
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42989
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 2, 3, 4, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42990
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42991
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 2, 3, 4, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42994
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x0063 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42995
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x0063 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 2, 3, 4, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42996
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x0063 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 42997
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x0063 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 2, 3, 4, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43000
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_028)
{

    {
        // line 43001
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 2, 3, 4, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43002
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43003
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 2, 3, 4, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43004
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43005
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x05D1, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 2, 3, 4, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43006
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43007
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 2, 3, 4, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43010
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x2680, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43011
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x2680, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43012
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_029)
{

    {
        // line 43013
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43014
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43015
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43016
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43017
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43018
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43019
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43020
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43021
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43022
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_030)
{

    {
        // line 43023
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43024
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x2680, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43025
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x2680, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43026
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43027
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43028
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43029
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43030
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43031
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43032
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_031)
{

    {
        // line 43033
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43034
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43035
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43036
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43037
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43038
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43039
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43040
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43041
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43044
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0062, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_032)
{

    {
        // line 43045
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0062, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43046
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43047
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43048
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43049
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43050
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43051
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43052
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43053
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43054
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_033)
{

    {
        // line 43055
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43056
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43057
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43058
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43059
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43060
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43061
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43062
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43063
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43064
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_034)
{

    {
        // line 43065
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43066
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43067
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43068
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43069
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43070
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43071
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43072
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43073
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43074
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_035)
{

    {
        // line 43075
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43078
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 5, 4, 3, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43079
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43080
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43081
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43082
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43083
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43084
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 1, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43085
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43086
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 5, 4, 3, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_036)
{

    {
        // line 43087
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43088
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 1, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43089
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43090
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 1, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43091
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43092
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 1, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43093
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43094
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 1, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43095
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43098
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_037)
{

    {
        // line 43099
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x2681, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43100
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43101
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43102
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43103
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43104
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43105
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43106
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43107
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43110
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0061, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_038)
{

    {
        // line 43111
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0061, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43112
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43113
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43114
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43115
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43116
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43117
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43118
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43119
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43120
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_039)
{

    {
        // line 43121
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43122
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43123
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43124
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43125
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43126
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43127
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43128
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43129
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43130
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_040)
{

    {
        // line 43131
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43132
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43133
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43136
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43137
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43138
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43139
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43140
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43141
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43142
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_041)
{

    {
        // line 43143
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43144
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43145
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43146
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43147
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43148
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43149
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43150
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43151
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43152
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_042)
{

    {
        // line 43153
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43154
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 5, 4, 3, 2, 1, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43155
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43156
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43157
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43158
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43159
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43162
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x2680, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43163
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x2680, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43164
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_043)
{

    {
        // line 43165
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43166
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43167
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43168
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43169
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43170
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43171
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43172
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43173
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43174
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_044)
{

    {
        // line 43175
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43176
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43177
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43178
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43179
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43182
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43183
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0062, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 2, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 3, 4, 5, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43184
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43185
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43186
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_045)
{

    {
        // line 43187
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43188
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43189
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43190
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43191
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43194
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x05D2, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43195
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x05D2, 0x005B, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43196
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43197
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43198
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_046)
{

    {
        // line 43199
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43200
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43201
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43202
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43203
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43204
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43205
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43206
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 1, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43207
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43208
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_047)
{

    {
        // line 43209
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x05D2, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43210
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 1, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 3, 2, 1, 4, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43211
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43214
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43215
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x2680, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43216
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43217
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43220
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 0, 1, 1, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 4, 3, 2, 5, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43221
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0061, 0x0029 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43222
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 5, 4, 3, 2, 1, 0, 6 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_048)
{

    {
        // line 43223
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43226
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x05D3 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43227
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x05D3 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 6, 5, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43230
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43231
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43234
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43235
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43236
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43237
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43238
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_049)
{

    {
        // line 43239
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43240
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43241
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43244
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43245
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43246
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43247
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43248
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x0061, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43249
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x0061, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43250
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_050)
{

    {
        // line 43251
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43254
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43255
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43256
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43257
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43258
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x05D0, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43259
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x05D0, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43260
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x05D0 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43261
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x05D0 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43264
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_051)
{

    {
        // line 43265
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43266
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x2681, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43267
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x2681, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43268
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43269
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43270
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43271
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x2681, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43272
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43273
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43274
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_052)
{

    {
        // line 43275
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43278
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43279
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43280
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43281
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x0061, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43282
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43283
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43284
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43285
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43286
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_053)
{

    {
        // line 43287
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x0061, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43288
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43289
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43290
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43291
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x0061, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43292
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43293
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43294
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43295
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43298
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_054)
{

    {
        // line 43299
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x05D0, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43300
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43301
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x05D0, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43302
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x05D0 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43303
        std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0029, 0x005B, 0x05D0 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43304
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x05D0, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43305
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x05D0, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43306
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x05D0, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43307
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x05D0, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43308
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x05D0 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_055)
{

    {
        // line 43309
        std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0029, 0x005B, 0x05D0 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43310
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x05D0, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43311
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x05D0, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43312
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x05D0 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43313
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x2680, 0x005B, 0x05D0 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43314
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x05D0 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43315
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x005B, 0x2680, 0x05D0 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43318
        std::vector<uint32_t> const cps = { 0x0061, 0x2680, 0x0028, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43319
        std::vector<uint32_t> const cps = { 0x0061, 0x2680, 0x0028, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43320
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x2680, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_056)
{

    {
        // line 43321
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x2680, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43322
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0029, 0x2680, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43323
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0029, 0x2680, 0x005B };
        std::vector<int> const expected_levels =
            { 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43324
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0029, 0x005B, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43325
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0029, 0x005B, 0x2680 };
        std::vector<int> const expected_levels =
            { 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43326
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x2680, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43327
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x2680, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43328
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x0029, 0x2680, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43329
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x0029, 0x2680, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43330
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x0029, 0x005B, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_057)
{

    {
        // line 43331
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x0029, 0x005B, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43332
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x0061, 0x2680, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43333
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x0061, 0x2680, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43334
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x0061, 0x005B, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43335
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x0061, 0x005B, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43338
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0062, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43339
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0062, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 2, 2, 2, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 0, 1, 2, 3 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43340
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0029, 0x0062, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43341
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0029, 0x0062, 0x005B };
        std::vector<int> const expected_levels =
            { 2, 2, 2, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 0, 1, 2, 3 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43342
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0029, 0x005B, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_058)
{

    {
        // line 43343
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0029, 0x005B, 0x0062 };
        std::vector<int> const expected_levels =
            { 2, 2, 2, 2, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43344
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x0029, 0x0062, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43345
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x0029, 0x0062, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 2, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43346
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x0029, 0x005B, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43347
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x0029, 0x005B, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 2, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43348
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x0061, 0x005B, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43349
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x0061, 0x005B, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 2, 3, 4, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43352
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x05D0, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43353
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x05D0, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43354
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0029, 0x05D0, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_059)
{

    {
        // line 43355
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0029, 0x05D0, 0x005B };
        std::vector<int> const expected_levels =
            { 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43356
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0029, 0x005B, 0x05D0 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43357
        std::vector<uint32_t> const cps = { 0x0061, 0x0028, 0x0029, 0x005B, 0x05D0 };
        std::vector<int> const expected_levels =
            { 2, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43358
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x05D0, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43359
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x05D0, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43360
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x0029, 0x05D0, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43361
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x0029, 0x05D0, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43362
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x0029, 0x005B, 0x05D0 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43363
        std::vector<uint32_t> const cps = { 0x0028, 0x0061, 0x0029, 0x005B, 0x05D0 };
        std::vector<int> const expected_levels =
            { 1, 2, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43364
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x0061, 0x05D0, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 1, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_060)
{

    {
        // line 43365
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x0061, 0x05D0, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43366
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x0061, 0x005B, 0x05D0 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 0, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43367
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x0061, 0x005B, 0x05D0 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43370
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43371
        std::vector<uint32_t> const cps = { 0x05D0, 0x2680, 0x0028, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43372
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43373
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x2680, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43374
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0029, 0x2680, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43375
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0029, 0x2680, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43376
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0029, 0x005B, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_061)
{

    {
        // line 43377
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0029, 0x005B, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43378
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43379
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x2680, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43380
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0029, 0x2680, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43381
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0029, 0x2680, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43382
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0029, 0x005B, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43383
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0029, 0x005B, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43384
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x05D0, 0x2680, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43385
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x05D0, 0x2680, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43386
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x05D0, 0x005B, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_062)
{

    {
        // line 43387
        std::vector<uint32_t> const cps = { 0x0028, 0x0029, 0x05D0, 0x005B, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43390
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43391
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43392
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0029, 0x0061, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43393
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0029, 0x0061, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43394
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0029, 0x005B, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43395
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0029, 0x005B, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 1, 2 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43396
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43397
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x0029, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 1, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43398
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0029, 0x0061, 0x005B };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }
}

TEST(bidi_character, bidi_character_061_063)
{

    {
        // line 43399
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0029, 0x0061, 0x005B };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 1 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 1);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 43400
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0029, 0x005B, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0 };
        std::vector<int> const levels =
            bidi_levels(cps.begin(), cps.end(), 0);
        int i = 0;
        for (int l : expected_levels) {
            if (0 <= l) {
                EXPECT_EQ(levels[i], l) << "i=" << i;
                ++i;
            }
        }
        EXPECT_EQ((int)levels.size(), i);

        std::vector<uint32_t> const expected_reordered_indices =
            { 0, 1, 2, 3, 4 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

}

max_stars_repo_name: eightysquirrels/text

max_issues_repo_name: eightysquirrels/text

max_forks_repo_name: eightysquirrels/text