-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmovement_attribute_test.go
More file actions
28 lines (26 loc) · 1.27 KB
/
Copy pathmovement_attribute_test.go
File metadata and controls
28 lines (26 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package bedsim
import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
"testing"
)
// TestMovementSpeedWithoutSprint checks sprint identity and preservation of other modifiers.
func TestMovementSpeedWithoutSprint(t *testing.T) {
for _, tt := range []struct {
name string
value, want float32
modifiers []protocol.AttributeModifier
}{
{name: "walking", value: 0.1, want: 0.1},
{name: "custom speed without sprint", value: 0.13, want: 0.13},
{name: "sprinting", value: 0.13, want: 0.1, modifiers: []protocol.AttributeModifier{{ID: "d208fc00-42aa-4aad-9276-d5446530de43", Amount: 0.3, Operation: 2, Operand: 2}}},
{name: "speed effect and sprint", value: 0.156, want: 0.120000005, modifiers: []protocol.AttributeModifier{{ID: "D208FC00-42AA-4AAD-9276-D5446530DE43", Amount: 0.3, Operation: 2, Operand: 2}}},
{name: "name alone is not identity", value: 0.13, want: 0.13, modifiers: []protocol.AttributeModifier{{ID: "custom", Name: "Sprinting speed boost", Amount: 0.3, Operation: 2, Operand: 2}}},
} {
t.Run(tt.name, func(t *testing.T) {
got := MovementSpeedWithoutSprint(protocol.Attribute{AttributeValue: protocol.AttributeValue{Value: tt.value}, Modifiers: tt.modifiers})
if got != tt.want {
t.Fatalf("got %.9g want %.9g", got, tt.want)
}
})
}
}