<commit_before>//
//  yas_ui_mesh_data_tests.mm
//

#import <XCTest/XCTest.h>
#import <iostream>
#import "yas_ui_mesh_data.h"

using namespace yas;

@interface yas_ui_mesh_data_tests : XCTestCase

@end

@implementation yas_ui_mesh_data_tests

- (void)setUp {
    [super setUp];
}

- (void)tearDown {
    [super tearDown];
}

- (void)test_create_mesh_data {
    ui::mesh_data mesh_data{4, 6};

    XCTAssertEqual(mesh_data.vertex_count(), 4);
    XCTAssertEqual(mesh_data.index_count(), 6);

    XCTAssertTrue(mesh_data.metal());
    XCTAssertTrue(mesh_data.renderable());
}

- (void)test_create_dynamic_mesh_data {
    ui::dynamic_mesh_data mesh_data{4, 6};

    XCTAssertEqual(mesh_data.vertex_count(), 4);
    XCTAssertEqual(mesh_data.index_count(), 6);
    XCTAssertEqual(mesh_data.max_vertex_count(), 4);
    XCTAssertEqual(mesh_data.max_index_count(), 6);

    XCTAssertTrue(mesh_data.metal());
    XCTAssertTrue(mesh_data.renderable());
}

- (void)test_create_null_mesh_data {
    ui::mesh_data mesh_data{nullptr};

    XCTAssertFalse(mesh_data);
}

- (void)test_create_null_dynamic_mesh_data {
    ui::dynamic_mesh_data dyn_mesh_data{nullptr};

    XCTAssertFalse(dyn_mesh_data);
}

- (void)test_write_mesh_data {
    ui::mesh_data mesh_data{4, 6};

    mesh_data.write([self](auto &vertices, auto &indices) {
        XCTAssertEqual(vertices.size(), 4);
        XCTAssertEqual(indices.size(), 6);

        vertices[0].position.x = 0.0f;
        vertices[0].position.y = 1.0f;
        vertices[1].position.x = 2.0f;
        vertices[1].position.y = 3.0f;
        vertices[2].position.x = 4.0f;
        vertices[2].position.y = 5.0f;
        vertices[3].position.x = 6.0f;
        vertices[3].position.y = 7.0f;

        vertices[0].tex_coord.x = 10.0f;
        vertices[0].tex_coord.y = 11.0f;
        vertices[1].tex_coord.x = 12.0f;
        vertices[1].tex_coord.y = 13.0f;
        vertices[2].tex_coord.x = 14.0f;
        vertices[2].tex_coord.y = 15.0f;
        vertices[3].tex_coord.x = 16.0f;
        vertices[3].tex_coord.y = 17.0f;

        indices[0] = 20.0f;
        indices[1] = 21.0f;
        indices[2] = 22.0f;
        indices[3] = 23.0f;
        indices[4] = 24.0f;
        indices[5] = 25.0f;
    });

    XCTAssertEqual(mesh_data.vertices()[0].position.x, 0.0f);
    XCTAssertEqual(mesh_data.vertices()[0].position.y, 1.0f);
    XCTAssertEqual(mesh_data.vertices()[1].position.x, 2.0f);
    XCTAssertEqual(mesh_data.vertices()[1].position.y, 3.0f);
    XCTAssertEqual(mesh_data.vertices()[2].position.x, 4.0f);
    XCTAssertEqual(mesh_data.vertices()[2].position.y, 5.0f);
    XCTAssertEqual(mesh_data.vertices()[3].position.x, 6.0f);
    XCTAssertEqual(mesh_data.vertices()[3].position.y, 7.0f);

    XCTAssertEqual(mesh_data.indices()[0], 20.0f);
    XCTAssertEqual(mesh_data.indices()[1], 21.0f);
    XCTAssertEqual(mesh_data.indices()[2], 22.0f);
    XCTAssertEqual(mesh_data.indices()[3], 23.0f);
    XCTAssertEqual(mesh_data.indices()[4], 24.0f);
    XCTAssertEqual(mesh_data.indices()[5], 25.0f);
}

- (void)test_set_variables_dynamic_mesh_data {
    ui::dynamic_mesh_data mesh_data{4, 6};

    XCTAssertEqual(mesh_data.vertex_count(), 4);
    XCTAssertEqual(mesh_data.index_count(), 6);
    XCTAssertEqual(mesh_data.max_vertex_count(), 4);
    XCTAssertEqual(mesh_data.max_index_count(), 6);

    mesh_data.set_vertex_count(0);
    mesh_data.set_index_count(0);

    XCTAssertEqual(mesh_data.vertex_count(), 0);
    XCTAssertEqual(mesh_data.index_count(), 0);
    XCTAssertEqual(mesh_data.max_vertex_count(), 4);
    XCTAssertEqual(mesh_data.max_index_count(), 6);

    mesh_data.set_vertex_count(4);
    mesh_data.set_index_count(6);

    XCTAssertEqual(mesh_data.vertex_count(), 4);
    XCTAssertEqual(mesh_data.index_count(), 6);

    XCTAssertThrows(mesh_data.set_vertex_count(5));
    XCTAssertThrows(mesh_data.set_index_count(7));
}

- (void)test_mesh_data_update_reason_to_string {
    XCTAssertEqual(to_string(ui::mesh_data_update_reason::data), "data");
    XCTAssertEqual(to_string(ui::mesh_data_update_reason::vertex_count), "vertex_count");
    XCTAssertEqual(to_string(ui::mesh_data_update_reason::index_count), "index_count");
    XCTAssertEqual(to_string(ui::mesh_data_update_reason::count), "count");
}

- (void)test_mesh_data_update_reason_ostream {
    std::cout << ui::mesh_data_update_reason::data << std::endl;
    std::cout << ui::mesh_data_update_reason::vertex_count << std::endl;
    std::cout << ui::mesh_data_update_reason::index_count << std::endl;
    std::cout << ui::mesh_data_update_reason::count << std::endl;
}

@end<commit_msg>fix tests<commit_after>//
//  yas_ui_mesh_data_tests.mm
//

#import <XCTest/XCTest.h>
#import <iostream>
#import "yas_ui_mesh_data.h"

using namespace yas;

@interface yas_ui_mesh_data_tests : XCTestCase

@end

@implementation yas_ui_mesh_data_tests

- (void)setUp {
    [super setUp];
}

- (void)tearDown {
    [super tearDown];
}

- (void)test_create_mesh_data {
    ui::mesh_data mesh_data{4, 6};

    XCTAssertEqual(mesh_data.vertex_count(), 4);
    XCTAssertEqual(mesh_data.index_count(), 6);

    XCTAssertTrue(mesh_data.metal());
    XCTAssertTrue(mesh_data.renderable());
}

- (void)test_create_dynamic_mesh_data {
    ui::dynamic_mesh_data mesh_data{4, 6};

    XCTAssertEqual(mesh_data.vertex_count(), 4);
    XCTAssertEqual(mesh_data.index_count(), 6);
    XCTAssertEqual(mesh_data.max_vertex_count(), 4);
    XCTAssertEqual(mesh_data.max_index_count(), 6);

    XCTAssertTrue(mesh_data.metal());
    XCTAssertTrue(mesh_data.renderable());
}

- (void)test_create_null_mesh_data {
    ui::mesh_data mesh_data{nullptr};

    XCTAssertFalse(mesh_data);
}

- (void)test_create_null_dynamic_mesh_data {
    ui::dynamic_mesh_data dyn_mesh_data{nullptr};

    XCTAssertFalse(dyn_mesh_data);
}

- (void)test_write_mesh_data {
    ui::mesh_data mesh_data{4, 6};

    mesh_data.write([self](auto &vertices, auto &indices) {
        XCTAssertEqual(vertices.size(), 4);
        XCTAssertEqual(indices.size(), 6);

        vertices[0].position.x = 0.0f;
        vertices[0].position.y = 1.0f;
        vertices[1].position.x = 2.0f;
        vertices[1].position.y = 3.0f;
        vertices[2].position.x = 4.0f;
        vertices[2].position.y = 5.0f;
        vertices[3].position.x = 6.0f;
        vertices[3].position.y = 7.0f;

        vertices[0].tex_coord.x = 10.0f;
        vertices[0].tex_coord.y = 11.0f;
        vertices[1].tex_coord.x = 12.0f;
        vertices[1].tex_coord.y = 13.0f;
        vertices[2].tex_coord.x = 14.0f;
        vertices[2].tex_coord.y = 15.0f;
        vertices[3].tex_coord.x = 16.0f;
        vertices[3].tex_coord.y = 17.0f;

        indices[0] = 20.0f;
        indices[1] = 21.0f;
        indices[2] = 22.0f;
        indices[3] = 23.0f;
        indices[4] = 24.0f;
        indices[5] = 25.0f;
    });

    XCTAssertEqual(mesh_data.vertices()[0].position.x, 0.0f);
    XCTAssertEqual(mesh_data.vertices()[0].position.y, 1.0f);
    XCTAssertEqual(mesh_data.vertices()[1].position.x, 2.0f);
    XCTAssertEqual(mesh_data.vertices()[1].position.y, 3.0f);
    XCTAssertEqual(mesh_data.vertices()[2].position.x, 4.0f);
    XCTAssertEqual(mesh_data.vertices()[2].position.y, 5.0f);
    XCTAssertEqual(mesh_data.vertices()[3].position.x, 6.0f);
    XCTAssertEqual(mesh_data.vertices()[3].position.y, 7.0f);

    XCTAssertEqual(mesh_data.indices()[0], 20.0f);
    XCTAssertEqual(mesh_data.indices()[1], 21.0f);
    XCTAssertEqual(mesh_data.indices()[2], 22.0f);
    XCTAssertEqual(mesh_data.indices()[3], 23.0f);
    XCTAssertEqual(mesh_data.indices()[4], 24.0f);
    XCTAssertEqual(mesh_data.indices()[5], 25.0f);
}

- (void)test_set_variables_dynamic_mesh_data {
    ui::dynamic_mesh_data mesh_data{4, 6};

    XCTAssertEqual(mesh_data.vertex_count(), 4);
    XCTAssertEqual(mesh_data.index_count(), 6);
    XCTAssertEqual(mesh_data.max_vertex_count(), 4);
    XCTAssertEqual(mesh_data.max_index_count(), 6);

    mesh_data.set_vertex_count(0);
    mesh_data.set_index_count(0);

    XCTAssertEqual(mesh_data.vertex_count(), 0);
    XCTAssertEqual(mesh_data.index_count(), 0);
    XCTAssertEqual(mesh_data.max_vertex_count(), 4);
    XCTAssertEqual(mesh_data.max_index_count(), 6);

    mesh_data.set_vertex_count(4);
    mesh_data.set_index_count(6);

    XCTAssertEqual(mesh_data.vertex_count(), 4);
    XCTAssertEqual(mesh_data.index_count(), 6);

    XCTAssertThrows(mesh_data.set_vertex_count(5));
    XCTAssertThrows(mesh_data.set_index_count(7));
}

- (void)test_mesh_data_update_reason_to_string {
    XCTAssertEqual(to_string(ui::mesh_data_update_reason::data), "data");
    XCTAssertEqual(to_string(ui::mesh_data_update_reason::vertex_count), "vertex_count");
    XCTAssertEqual(to_string(ui::mesh_data_update_reason::index_count), "index_count");
    XCTAssertEqual(to_string(ui::mesh_data_update_reason::render_buffer), "render_buffer");
    XCTAssertEqual(to_string(ui::mesh_data_update_reason::count), "count");
}

- (void)test_mesh_data_update_reason_ostream {
    std::cout << ui::mesh_data_update_reason::data << std::endl;
    std::cout << ui::mesh_data_update_reason::vertex_count << std::endl;
    std::cout << ui::mesh_data_update_reason::index_count << std::endl;
    std::cout << ui::mesh_data_update_reason::render_buffer << std::endl;
    std::cout << ui::mesh_data_update_reason::count << std::endl;
}

@end
{'fraction_non_alphanumeric': 0.1552203679931536, 'fraction_numerical': 0.03423192126658109, 'mean_word_length': 4.321001707455891, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1680332', 'n_tokens_mistral': 3758, 'n_tokens_neox': 3595, 'n_words': 389}