Skip to content

Commit 5e9b965

Browse files
authored
Merge pull request #931 from 0x53A/dev-add-itest-enum_test
[itest] add enum_test to mod.rs
2 parents 10e5e0e + adf2b50 commit 5e9b965

File tree

2 files changed

+44
-36
lines changed

2 files changed

+44
-36
lines changed

itest/rust/src/object_tests/enum_test.rs

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,30 @@ use godot::builtin::varray;
1010
use godot::classes::input::CursorShape;
1111
use godot::classes::mesh::PrimitiveType;
1212
use godot::classes::{time, ArrayMesh};
13-
use godot::global::{Orientation, Key};
13+
use godot::global::{Key, Orientation};
14+
use godot::obj::NewGd;
1415
use std::collections::HashSet;
1516

1617
#[itest]
1718
fn enum_ords() {
1819
use godot::obj::EngineEnum;
19-
assert_eq!(CursorShape::CURSOR_ARROW.ord(), 0);
20-
assert_eq!(CursorShape::CURSOR_IBEAM.ord(), 1);
21-
assert_eq!(CursorShape::CURSOR_POINTING_HAND.ord(), 2);
22-
assert_eq!(CursorShape::CURSOR_CROSS.ord(), 3);
23-
assert_eq!(CursorShape::CURSOR_WAIT.ord(), 4);
24-
assert_eq!(CursorShape::CURSOR_BUSY.ord(), 5);
25-
assert_eq!(CursorShape::CURSOR_DRAG.ord(), 6);
26-
assert_eq!(CursorShape::CURSOR_CAN_DROP.ord(), 7);
27-
assert_eq!(CursorShape::CURSOR_FORBIDDEN.ord(), 8);
28-
assert_eq!(CursorShape::CURSOR_VSIZE.ord(), 9);
29-
assert_eq!(CursorShape::CURSOR_HSIZE.ord(), 10);
30-
assert_eq!(CursorShape::CURSOR_BDIAGSIZE.ord(), 11);
31-
assert_eq!(CursorShape::CURSOR_FDIAGSIZE.ord(), 12);
32-
assert_eq!(CursorShape::CURSOR_MOVE.ord(), 13);
33-
assert_eq!(CursorShape::CURSOR_VSPLIT.ord(), 14);
34-
assert_eq!(CursorShape::CURSOR_HSPLIT.ord(), 15);
35-
assert_eq!(CursorShape::CURSOR_HELP.ord(), 16);
20+
assert_eq!(CursorShape::ARROW.ord(), 0);
21+
assert_eq!(CursorShape::IBEAM.ord(), 1);
22+
assert_eq!(CursorShape::POINTING_HAND.ord(), 2);
23+
assert_eq!(CursorShape::CROSS.ord(), 3);
24+
assert_eq!(CursorShape::WAIT.ord(), 4);
25+
assert_eq!(CursorShape::BUSY.ord(), 5);
26+
assert_eq!(CursorShape::DRAG.ord(), 6);
27+
assert_eq!(CursorShape::CAN_DROP.ord(), 7);
28+
assert_eq!(CursorShape::FORBIDDEN.ord(), 8);
29+
assert_eq!(CursorShape::VSIZE.ord(), 9);
30+
assert_eq!(CursorShape::HSIZE.ord(), 10);
31+
assert_eq!(CursorShape::BDIAGSIZE.ord(), 11);
32+
assert_eq!(CursorShape::FDIAGSIZE.ord(), 12);
33+
assert_eq!(CursorShape::MOVE.ord(), 13);
34+
assert_eq!(CursorShape::VSPLIT.ord(), 14);
35+
assert_eq!(CursorShape::HSPLIT.ord(), 15);
36+
assert_eq!(CursorShape::HELP.ord(), 16);
3637
}
3738

3839
#[itest]
@@ -48,18 +49,18 @@ fn enum_equality() {
4849
#[itest]
4950
fn enum_hash() {
5051
let mut months = HashSet::new();
51-
months.insert(time::Month::MONTH_JANUARY);
52-
months.insert(time::Month::MONTH_FEBRUARY);
53-
months.insert(time::Month::MONTH_MARCH);
54-
months.insert(time::Month::MONTH_APRIL);
55-
months.insert(time::Month::MONTH_MAY);
56-
months.insert(time::Month::MONTH_JUNE);
57-
months.insert(time::Month::MONTH_JULY);
58-
months.insert(time::Month::MONTH_AUGUST);
59-
months.insert(time::Month::MONTH_SEPTEMBER);
60-
months.insert(time::Month::MONTH_OCTOBER);
61-
months.insert(time::Month::MONTH_NOVEMBER);
62-
months.insert(time::Month::MONTH_DECEMBER);
52+
months.insert(time::Month::JANUARY);
53+
months.insert(time::Month::FEBRUARY);
54+
months.insert(time::Month::MARCH);
55+
months.insert(time::Month::APRIL);
56+
months.insert(time::Month::MAY);
57+
months.insert(time::Month::JUNE);
58+
months.insert(time::Month::JULY);
59+
months.insert(time::Month::AUGUST);
60+
months.insert(time::Month::SEPTEMBER);
61+
months.insert(time::Month::OCTOBER);
62+
months.insert(time::Month::NOVEMBER);
63+
months.insert(time::Month::DECEMBER);
6364

6465
assert_eq!(months.len(), 12);
6566
}
@@ -68,15 +69,15 @@ fn enum_hash() {
6869
// This fails upon calling the function, we don't actually need to make a good call.
6970
#[itest]
7071
fn add_surface_from_arrays() {
71-
let mut mesh = ArrayMesh::new();
72-
mesh.add_surface_from_arrays(PrimitiveType::PRIMITIVE_TRIANGLES, varray![]);
72+
let mut mesh = ArrayMesh::new_gd();
73+
mesh.add_surface_from_arrays(PrimitiveType::TRIANGLES, &varray![]);
7374
}
7475

7576
#[itest]
7677
fn enum_as_str() {
7778
use godot::obj::EngineEnum;
78-
assert_eq!(Orientation::Vertical.as_str(), "VERTICAL");
79-
assert_eq!(Orientation::Horizontal.as_str(), "HORIZONTAL");
79+
assert_eq!(Orientation::VERTICAL.as_str(), "VERTICAL");
80+
assert_eq!(Orientation::HORIZONTAL.as_str(), "HORIZONTAL");
8081

8182
assert_eq!(Key::NONE.as_str(), "NONE");
8283
assert_eq!(Key::SPECIAL.as_str(), "SPECIAL");
@@ -88,8 +89,14 @@ fn enum_as_str() {
8889
#[itest]
8990
fn enum_godot_name() {
9091
use godot::obj::EngineEnum;
91-
assert_eq!(Orientation::Vertical.godot_name(), Orientation::Vertical.as_str());
92-
assert_eq!(Orientation::Horizontal.godot_name(), Orientation::Vertical.as_str());
92+
assert_eq!(
93+
Orientation::VERTICAL.godot_name(),
94+
Orientation::VERTICAL.as_str()
95+
);
96+
assert_eq!(
97+
Orientation::HORIZONTAL.godot_name(),
98+
Orientation::HORIZONTAL.as_str()
99+
);
93100

94101
assert_eq!(Key::NONE.godot_name(), "KEY_NONE");
95102
assert_eq!(Key::SPECIAL.godot_name(), "KEY_SPECIAL");

itest/rust/src/object_tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ mod base_test;
99
mod class_name_test;
1010
mod class_rename_test;
1111
mod dynamic_call_test;
12+
mod enum_test;
1213
// `get_property_list` is only supported in Godot 4.3+
1314
#[cfg(since_api = "4.3")]
1415
mod get_property_list_test;

0 commit comments

Comments
 (0)