diff options
author | Magnus Lundborg <lundborg.magnus@gmail.com> | 2014-08-25 19:42:18 (GMT) |
---|---|---|
committer | Magnus Lundborg <lundborg.magnus@gmail.com> | 2014-08-25 19:42:18 (GMT) |
commit | c28d63481bb1d6cbfa9075d923e2d5ff9e33d5d5 (patch) | |
tree | 6181fba79876abbf1bfd2433f4449fd806b62787 /src/tests/tng_io_testing.c | |
parent | 8f1b8df3eac919d70c9351e09bebf52f885e6624 (diff) |
Improved tests
Test writing double velocities using utility functions.
Change-Id: Ibbf141db75ec502db1d10f4280f0047ccc8367dc
Diffstat (limited to 'src/tests/tng_io_testing.c')
-rw-r--r-- | src/tests/tng_io_testing.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/tests/tng_io_testing.c b/src/tests/tng_io_testing.c index e4ffee5..2d04deb 100644 --- a/src/tests/tng_io_testing.c +++ b/src/tests/tng_io_testing.c @@ -387,6 +387,9 @@ static tng_function_status tng_test_molecules(tng_trajectory_t traj) return(stat); } + free(bonds_from); + free(bonds_to); + return(TNG_SUCCESS); } @@ -1075,6 +1078,8 @@ tng_function_status tng_test_utility_functions(tng_trajectory_t traj, const char tng_function_status tng_test_append(tng_trajectory_t traj, const char hash_mode) { char str[TNG_MAX_STR_LEN]; + int64_t n_frames, n_particles, i; + double time, *velocities; tng_function_status stat; stat = tng_util_trajectory_open(TNG_EXAMPLE_FILES_DIR "tng_test.tng", 'a', &traj); @@ -1136,6 +1141,29 @@ tng_function_status tng_test_append(tng_trajectory_t traj, const char hash_mode) return(stat); } + tng_num_frames_get(traj, &n_frames); + tng_frame_set_of_frame_find(traj, n_frames - 1); + tng_util_time_of_frame_get(traj, n_frames - 1, &time); + time += TIME_PER_FRAME; + tng_num_particles_get(traj, &n_particles); + + velocities = malloc(sizeof(double) * n_particles * 3); + if(!velocities) + { + printf("Cannot allocate memory. %s: %d\n", + __FILE__, __LINE__); + return(TNG_CRITICAL); + } + + for(i = 0; i < n_particles * 3; i++) + { + velocities[i] = i; + } + + tng_util_vel_with_time_double_write(traj, n_frames, time, velocities); + + free(velocities); + stat = tng_util_trajectory_close(&traj); return(stat); |