-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathtest_H5T.R
More file actions
76 lines (55 loc) · 2.03 KB
/
test_H5T.R
File metadata and controls
76 lines (55 loc) · 2.03 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
library(rhdf5)
test_that("String padding can be read and changed", {
tid <- H5Tcopy("H5T_C_S1")
expect_silent(tid2 <- H5Tset_strpad(dtype_id = tid, strpad = "NULLTERM"))
expect_identical(H5Tget_strpad(tid), 0L)
expect_silent(tid2 <- H5Tset_strpad(dtype_id = tid, strpad = "NULLPAD"))
expect_identical(H5Tget_strpad(tid), 1L)
expect_silent(tid2 <- H5Tset_strpad(dtype_id = tid, strpad = "SPACEPAD"))
expect_identical(H5Tget_strpad(tid), 2L)
expect_silent(H5Tclose(tid))
})
test_that("String character set can be read and changed", {
tid <- H5Tcopy("H5T_C_S1")
expect_identical(H5Tget_cset(tid), 0L)
expect_silent(H5Tset_cset(tid, cset = "UTF-8")) |>
expect_gte(0)
expect_identical(H5Tget_cset(tid), 1L)
expect_silent(H5Tclose(tid))
})
test_that("H5T error handling works", {
tid <- H5Tcopy("H5T_C_S1")
expect_error(H5Tget_strpad())
expect_error(H5Tset_strpad(dtype_id = tid, strpad = "FOOBAA"))
expect_error(H5Tget_size())
expect_error(H5Tset_size(dtype_id = "H5T_C_S1"))
expect_error(H5Tget_cset())
expect_error(H5Tget_cset(dtype_id = tid, cset = "FOOBAA"))
expect_silent(H5Tclose(tid))
})
test_that("Precision can be modified", {
integer_tid <- H5Tcopy("H5T_STD_U32LE")
expect_identical(H5Tget_precision(integer_tid), 32L)
expect_true(H5Tset_precision(integer_tid, precision = 8))
expect_identical(H5Tget_precision(integer_tid), 8L)
expect_error(
H5Tget_precision(),
regexp = "Argument 'dtype_id' must be supplied"
)
expect_error(
H5Tset_precision(),
regexp = "Argument 'dtype_id' must be supplied"
)
expect_error(
H5Tset_precision(integer_tid, 0),
regexp = "'precision' argument must be greater than 0"
)
expect_silent(H5Tclose(integer_tid))
})
test_that("Enum datatypes can be created and modified", {
expect_silent(tid <- H5Tenum_create(dtype_id = "H5T_NATIVE_UCHAR"))
expect_is(tid, "character")
expect_true(H5Tenum_insert(tid, name = "TRUE", value = 1L))
expect_true(H5Tenum_insert(tid, name = "FALSE", value = 0L))
expect_silent(H5Tclose(tid))
})