@@ -2,12 +2,43 @@ package sk.ai.net
22
33import kotlin.test.Test
44import kotlin.test.assertEquals
5+ import kotlin.test.assertFalse
6+ import kotlin.test.assertContentEquals
57
68class ShapeTest {
79
810 @Test
9- fun `test scalar` () {
10- val shape = Shape (0 )
11- assertEquals(shape, Shape ( 1 , 2 ) )
11+ fun volumeIsProductOfDimensions () {
12+ val shape = Shape (2 , 3 , 4 )
13+ assertEquals(24 , shape.volume )
1214 }
13- }
15+
16+ @Test
17+ fun rankIsNumberOfDimensions () {
18+ val shape = Shape (2 , 3 )
19+ assertEquals(2 , shape.rank)
20+ }
21+
22+ @Test
23+ fun equalityChecksAllDimensions () {
24+ val shape1 = Shape (2 , 3 )
25+ val shape2 = Shape (2 , 3 )
26+ val shape3 = Shape (3 , 2 )
27+ assertEquals(shape1, shape2)
28+ assertFalse(shape1 == shape3)
29+ }
30+
31+ @Test
32+ fun constructorCopiesDimensions () {
33+ val dims = intArrayOf(2 , 3 )
34+ val shape = Shape (* dims)
35+ dims[0 ] = 5
36+ assertContentEquals(intArrayOf(2 , 3 ), shape.dimensions)
37+ }
38+
39+ @Test
40+ fun toStringContainsSizeInformation () {
41+ val shape = Shape (2 , 3 )
42+ assertEquals(" Shape: Dimensions = [2 x 3], Size (Volume) = 6" , shape.toString())
43+ }
44+ }
0 commit comments