// 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_045_000)
{

    {
        // line 31501
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x2680, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31502
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x2680, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31503
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x2680, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31504
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x005D, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31505
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x005D, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31506
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x05D1, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31507
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x05D1, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31508
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x05D1, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31509
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x05D1, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31510
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x0029, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_001)
{

    {
        // line 31511
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x0029, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31512
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x0029, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31513
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x2680, 0x005B, 0x0029, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31514
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x05D1, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31515
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x05D1, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31516
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x0029, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31517
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x0029, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31518
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x0029, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31519
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x2680, 0x0029, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31520
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x2680, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_002)
{

    {
        // line 31521
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x2680, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31522
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x2680, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31523
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x2680, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31524
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x005D, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31525
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x005D, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31526
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x05D1, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31527
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x05D1, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31528
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x0029, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31529
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x0029, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31530
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x0029, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_003)
{

    {
        // line 31531
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x0029, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31532
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x2680, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31533
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x2680, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31534
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x2680, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31535
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x2680, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31536
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x005D, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31537
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x005D, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31538
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x2680, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31539
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x2680, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31540
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x2680, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_004)
{

    {
        // line 31541
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x2680, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31542
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x005D, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31543
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x005D, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31544
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x05D1, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31545
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x05D1, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31546
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x0029, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31547
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x0029, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31548
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x0029, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31549
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x0029, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31550
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x2680, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_005)
{

    {
        // line 31551
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x2680, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31552
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x2680, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31553
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x2680, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31554
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x005D, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31555
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x005D, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31556
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x2680, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31557
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x2680, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31558
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x2680, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31559
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x2680, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31560
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x005D, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_006)
{

    {
        // line 31561
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x005D, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31562
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x2680, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31563
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x2680, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31564
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x2680, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31565
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x2680, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31566
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x005D, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31567
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x005D, 0x2680, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31570
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31571
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31572
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_007)
{

    {
        // line 31573
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31574
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31575
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31576
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x0062, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31577
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x0062, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31578
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31579
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31580
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x0062, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31581
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x0062, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31582
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_008)
{

    {
        // line 31583
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31584
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31585
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31586
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31587
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31588
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31589
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31590
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x0062, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31591
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x0062, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31592
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_009)
{

    {
        // line 31593
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31594
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x0062, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31595
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x0062, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31596
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31597
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31598
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x0062, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31599
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x0062, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31600
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x0062, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31601
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x0062, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31604
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x0063, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_010)
{

    {
        // line 31605
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x0063, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31606
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D, 0x0063 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31607
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D, 0x0063 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31608
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D, 0x0063 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31609
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D, 0x0063 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 5, 6, 7, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31610
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D, 0x0063 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31611
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D, 0x0063 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 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 =
            { 5, 6, 7, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31612
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x0063, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31613
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x0063, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31614
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D, 0x0063 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_011)
{

    {
        // line 31615
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D, 0x0063 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31616
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D, 0x0063 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31617
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D, 0x0063 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 5, 6, 7, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31618
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D, 0x0063 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31619
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D, 0x0063 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 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 =
            { 5, 6, 7, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31620
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x0062, 0x005D, 0x0063 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31621
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x0062, 0x005D, 0x0063 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 2, 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 =
            { 5, 6, 7, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31624
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x05D1, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31625
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x05D1, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31626
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_012)
{

    {
        // line 31627
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31628
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31629
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31630
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x0062, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31631
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x0062, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31632
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31633
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31634
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x0062, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31635
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x0062, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31636
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_013)
{

    {
        // line 31637
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31638
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x05D1, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31639
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x05D1, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31640
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31641
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31642
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31643
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 2, 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 =
            { 7, 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 31644
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x0062, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31645
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x0062, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31646
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_014)
{

    {
        // line 31647
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31648
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x0062, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31649
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x0062, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31650
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31651
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31652
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x0062, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31653
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x0062, 0x05D1, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31654
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x0062, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31655
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x0062, 0x005D, 0x05D1 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31658
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x2680, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_015)
{

    {
        // line 31659
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x2680, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31660
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31661
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31662
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31663
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31664
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31665
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31666
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31667
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31668
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_016)
{

    {
        // line 31669
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31670
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31671
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31672
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31673
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31674
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31675
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31676
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31677
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31678
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_017)
{

    {
        // line 31679
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31680
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31681
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31682
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31683
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31684
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31685
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31686
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31687
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31688
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_018)
{

    {
        // line 31689
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31690
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x2680, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31691
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x2680, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31692
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31693
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31694
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31695
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31696
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31697
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31698
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_019)
{

    {
        // line 31699
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31700
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31701
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31702
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31703
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31704
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31705
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31706
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31707
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31708
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_020)
{

    {
        // line 31709
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31710
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31711
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31712
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31713
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31714
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31715
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31716
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31717
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31718
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_021)
{

    {
        // line 31719
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31720
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31721
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31722
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31723
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31724
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31725
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31726
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31727
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31728
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_022)
{

    {
        // line 31729
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31730
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31731
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31732
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31733
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31734
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31735
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31736
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31737
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31738
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_023)
{

    {
        // line 31739
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31742
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0062, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31743
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x0062, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31744
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31745
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31746
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31747
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31748
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31749
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31750
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_024)
{

    {
        // line 31751
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31752
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31753
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31754
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31755
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31756
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31757
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31758
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31759
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31760
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_025)
{

    {
        // line 31761
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31762
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31763
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31764
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31765
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31766
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31767
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31768
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31769
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31770
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_026)
{

    {
        // line 31771
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31772
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31773
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31774
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31775
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31776
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31777
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31778
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31779
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31780
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_027)
{

    {
        // line 31781
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31782
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31783
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31784
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31785
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31786
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31787
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31788
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31789
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31790
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_028)
{

    {
        // line 31791
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31792
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31793
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31794
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31795
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31796
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31797
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31798
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31799
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31800
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_029)
{

    {
        // line 31801
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31802
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31803
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31804
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31805
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31806
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31807
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31808
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31809
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31810
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_030)
{

    {
        // line 31811
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31812
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31813
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31814
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31815
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31816
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31817
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31818
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31819
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31820
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_031)
{

    {
        // line 31821
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31822
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31823
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31826
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 2, 5, 4, 3, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31827
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31828
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31829
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31830
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31831
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31832
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_032)
{

    {
        // line 31833
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31834
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31835
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31836
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 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 =
            { 0, 1, 2, 3, 4, 7, 6, 5 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31837
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31838
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31839
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31840
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31841
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31842
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 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 =
            { 0, 1, 2, 3, 4, 7, 6, 5 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_033)
{

    {
        // line 31843
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31844
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 0, 0, 0, 0, 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 =
            { 0, 1, 2, 3, 4, 7, 6, 5 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31845
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31846
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 2, 5, 4, 3, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31847
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31848
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31849
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31850
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31851
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31852
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_034)
{

    {
        // line 31853
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31854
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31855
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31856
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 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 =
            { 0, 1, 2, 3, 4, 7, 6, 5 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31857
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 2, 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 =
            { 7, 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 31858
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31859
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31860
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31861
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31862
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 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 =
            { 0, 1, 2, 3, 4, 7, 6, 5 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_035)
{

    {
        // line 31863
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31864
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 0, 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 =
            { 0, 1, 2, 3, 4, 7, 6, 5 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31865
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31866
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31867
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31868
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31869
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31870
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0, 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 =
            { 0, 1, 2, 3, 4, 7, 6, 5 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31871
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31872
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 0, 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 =
            { 0, 1, 2, 3, 4, 7, 6, 5 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_036)
{

    {
        // line 31873
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31874
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 0, 0, 1, 0, 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 =
            { 0, 1, 2, 3, 4, 7, 6, 5 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31875
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31878
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x2681, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 6, 5, 4, 3, 2, 1, 0, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31879
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x2681, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31880
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x2681, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31881
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x2681, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31882
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31883
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31884
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x2681, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_037)
{

    {
        // line 31885
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x2681, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31886
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31887
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31888
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31889
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31890
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x2681, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31891
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x2681, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31892
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31893
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31894
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_038)
{

    {
        // line 31895
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31896
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31897
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31898
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x2681, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31899
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x2681, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31900
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31901
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31902
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31903
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31904
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_039)
{

    {
        // line 31905
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31906
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31907
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x005D, 0x2681 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31910
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0061, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31911
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x0061, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31912
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0061, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31913
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0061, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31914
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31915
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31916
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_040)
{

    {
        // line 31917
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31918
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0061, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31919
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0061, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31920
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31921
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31922
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31923
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31924
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31925
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31926
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_041)
{

    {
        // line 31927
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31928
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x005D, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31929
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x005D, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31930
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0061, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31931
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0061, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31932
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31933
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31934
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31935
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31936
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_042)
{

    {
        // line 31937
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31938
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31939
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31940
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31941
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31942
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x2680, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31943
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x2680, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31944
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31945
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31946
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_043)
{

    {
        // line 31947
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31948
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0061, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31949
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0061, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31950
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31951
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31952
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31953
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31954
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31955
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31956
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_044)
{

    {
        // line 31957
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31958
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31959
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31960
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x2680, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31961
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x2680, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31962
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31963
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31964
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31965
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31966
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_045)
{

    {
        // line 31967
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31968
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31969
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31970
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x005D, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31971
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x005D, 0x2680, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31974
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 6, 5, 4, 3, 2, 1, 0, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31975
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x05D2, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31976
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 6, 5, 4, 3, 2, 1, 0, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31977
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31978
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 6, 5, 4, 3, 2, 1, 0, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_046)
{

    {
        // line 31979
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31980
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31981
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31982
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 6, 5, 4, 3, 2, 1, 0, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31983
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31984
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 6, 5, 4, 3, 2, 1, 0, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31985
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31986
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31987
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31988
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 6, 5, 4, 3, 2, 1, 0, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_047)
{

    {
        // line 31989
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31990
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31991
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31992
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x005D, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31993
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x005D, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31994
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 6, 5, 4, 3, 2, 1, 0, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31995
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31996
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 6, 5, 4, 3, 2, 1, 0, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 31997
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 31998
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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_045_048)
{

    {
        // line 31999
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32000
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 6, 5, 4, 3, 2, 1, 0, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32001
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32002
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32003
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32004
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32005
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32006
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x2680, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 6, 5, 4, 3, 2, 1, 0, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32007
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x2680, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32008
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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_045_049)
{

    {
        // line 32009
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32010
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32011
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32012
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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 =
            { 0, 5, 4, 3, 2, 1, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32013
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32014
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32015
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32016
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32017
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32018
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_050)
{

    {
        // line 32019
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32020
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32021
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32022
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32023
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32024
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x2680, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 3, 6, 5, 4, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32025
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x2680, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32026
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 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 =
            { 0, 1, 2, 3, 7, 6, 5, 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 32027
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32028
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 0, 0, 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 =
            { 0, 1, 2, 3, 7, 6, 5, 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_045_051)
{

    {
        // line 32029
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32030
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 3, 6, 5, 4, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32031
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32032
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 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 =
            { 0, 1, 2, 3, 7, 6, 5, 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 32033
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32034
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x005D, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 0, 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 =
            { 0, 1, 2, 3, 7, 6, 5, 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 32035
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x005D, 0x2680, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32038
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x2680, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32039
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x2680, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32040
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_052)
{

    {
        // line 32041
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32042
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32043
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32044
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32045
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32046
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32047
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32048
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32049
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32050
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_053)
{

    {
        // line 32051
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32052
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x0061, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32053
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x0061, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32054
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x0061, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32055
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x0061, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32056
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32057
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32058
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32059
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32060
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_054)
{

    {
        // line 32061
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32062
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x0061, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32063
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x0061, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32064
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32065
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32066
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x0061, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32067
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x0061, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32068
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32069
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32070
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_055)
{

    {
        // line 32071
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32072
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32073
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32074
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32075
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32076
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x0061, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32077
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x0061, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32078
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32079
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32080
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x0061, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_056)
{

    {
        // line 32081
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x0061, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32082
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32083
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32084
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32085
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32086
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32087
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32090
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32091
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32092
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_057)
{

    {
        // line 32093
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32094
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32095
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32096
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32097
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32098
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32099
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32100
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x0061, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32101
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x0061, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 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 =
            { 5, 6, 7, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32102
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_058)
{

    {
        // line 32103
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32104
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32105
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32106
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32107
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 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 =
            { 5, 6, 7, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32108
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32109
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 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 =
            { 5, 6, 7, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32110
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32111
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x0062, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32112
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_059)
{

    {
        // line 32113
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32114
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32115
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 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 =
            { 5, 6, 7, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32116
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32117
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 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 =
            { 5, 6, 7, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32118
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32119
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x005D, 0x0062 };
        std::vector<int> const expected_levels =
            { 1, 1, 1, 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 =
            { 5, 6, 7, 4, 3, 2, 1, 0 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 1);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32122
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x05D2, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32123
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x05D2, 0x005B, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32124
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_060)
{

    {
        // line 32125
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32126
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32127
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32128
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32129
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32130
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32131
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32132
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32133
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32134
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_061)
{

    {
        // line 32135
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32136
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x0061, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32137
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x0061, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32138
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x0061, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32139
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x0061, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32140
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32141
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32142
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32143
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32144
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_062)
{

    {
        // line 32145
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32146
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x0061, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32147
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x0061, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32148
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32149
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32150
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x0061, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32151
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x0061, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32152
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 1, 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 =
            { 4, 3, 2, 1, 0, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32153
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32154
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_063)
{

    {
        // line 32155
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x05D2, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32156
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32157
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32158
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32159
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32160
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x0061, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32161
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x0061, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32162
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32163
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32164
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x0061, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_064)
{

    {
        // line 32165
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x0061, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32166
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32167
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32168
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 0, 1, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32169
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x05D2, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32170
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 0, 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, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32171
        std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x005D, 0x05D2 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32174
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 6, 5, 4, 3, 2, 1, 0, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32175
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x2680, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32176
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_065)
{

    {
        // line 32177
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32178
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32179
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32180
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x05D2, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32181
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x05D2, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32182
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x05D2, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32183
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x05D2, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32184
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32185
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32186
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_066)
{

    {
        // line 32187
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32188
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32189
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x2680, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32190
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 0, 1, 1, 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, 3, 2, 1, 4, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32191
        std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x005D, 0x2680 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32194
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0061, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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, 1, 4, 3, 2, 5, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32195
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0061, 0x0029, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32196
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

    {
        // line 32197
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32198
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (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_045_067)
{

    {
        // line 32199
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x005D, 0x0061 };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 7, 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 32200
        std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x05D2, 0x0061, 0x005D };
        std::vector<int> const expected_levels =
            { 1, 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 =
            { 5, 4, 3, 2, 1, 0, 6, 7 };
        std::vector<int> const reordered =
            bidi_reordered_indices(cps.begin(), cps.end(), 0);
        i = 0;
        for (int idx : expected_reordered_indices) {
            EXPECT_EQ(reordered[i], cps[idx])
                << std::hex
                << " 0x" << reordered[i]
                << " 0x" << cps[idx]
                << std::dec << " i=" << i;
            ++i;
        }
    }

}
