Skip to content

Unit tests - #10

Merged
CrSjimo merged 5 commits into
mainfrom
unit-tests
Aug 15, 2026
Merged

Unit tests#10
CrSjimo merged 5 commits into
mainfrom
unit-tests

Conversation

@SineStriker

Copy link
Copy Markdown
Contributor

No description provided.

The three module directories sat beside opendspx/ rather than inside it, so a
package installing into a shared prefix -- which is where vcpkg puts this one --
took four of the top-level names there instead of one. They are subdirectories
of opendspx/ now, the way llvm/ holds ADT/ and Support/, and an include reads
<opendspx/serializer/serializer.h>.

Three changes to what the serializer does travel with it, because they live in
the files that moved:

- A workspace maps a key to an object rather than to any value, which is what
  the format says it holds. An entry that is not one is now turned down instead
  of carried through.
- A rejected document answers with a code, a byte offset and a line and column,
  following the same change in stdcorelib. Matching on the wording was the only
  way to act on the failure before, and pointing at the place meant counting
  newlines.
- The key of a map entry joins the error path, so a bad workspace entry reads
  $.content.workspace.loop rather than naming only the workspace it was in. The
  entries used to be values nothing could reject, so the path never showed.
The guards said MODEL for headers that sit in no such directory, and the ones
under serializer/private/ said SERIALIZATION for two of the three and SERIALIZER
for the other. Each is now the path with the separators replaced, so a new header
needs no decision and a moved one has one obvious answer. PRIVATE is left out of
the three private ones, since the _p already says it.
MidiFile::load returns a bool, and the caller was reading it as the whole
verdict. It is not: a file that stops in the middle of a field reaches the
stream reader as a failure and comes out as std::ios_base::failure, past a
signature that promised an Error out parameter and nothing else. An editor
opening a half-written file got a crash where it had asked for InvalidMidiData.
What was there ran one document through the serializer and printed the bytes,
so it said a crash had not happened and nothing else. This is eighty-four cases
over the four modules, in one binary, laid out the way stdcorelib's is: a
directory per module, and a module's cases come in only when that module was
built.

Nothing that the compiler already guarantees is covered. What is:

- serializer: a round trip over a model with both clip kinds, both singer kinds
  and both curve kinds; that writing what was read gives the same bytes; that a
  number keeps the form it was written in; that text which is not UTF-8 is
  replaced rather than fatal; the zstd frame and its detection; and each way a
  document can be turned down, with the position it was turned down at.
- jsonconverterv1: the mapping machinery on its own -- the shape of an error
  path through arrays and objects, every data type mismatch, the bounds a range
  error carries, both enum kinds, polymorphic dispatch and its four failures,
  and that writing checks what reading checks.
- interpolator: that a curve meets its nodes, that a straight run of anchors
  stays straight, and that a run which turns around does not bulge past the
  anchor it turns at.
- converter: every rule in isValid on its own, and a model out through a MIDI
  file and back.

The libraries come before Boost in target_link_libraries on purpose. Boost.Test
usually comes out of a vcpkg tree, that tree is one include directory for
everything in it, and the one here carries an older copy of a dependency this
project also builds against.
@CrSjimo

CrSjimo commented Aug 15, 2026

Copy link
Copy Markdown
Member

@copilot 请你概括此pr中,除了单纯的重命名外的其他改动

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown

@copilot 请你概括此pr中,除了单纯的重命名外的其他改动

除去重命名/目录调整,主要还有这些改动:

  1. 引入了完整的 Boost.Test 自动化回归测试框架(tests/auto、新的 main.cpp、CMake 集成)。
  2. 新增了多组实际测试用例,覆盖 MIDI 转换、序列化/反序列化,以及多种插值器逻辑(mix/parameter/vibrato 等)。
  3. 测试构建入口从原先的单一 tests/main.cpp 调整为按模块组织的自动测试结构,并更新了对应的 tests/CMakeLists.txt

Copilot AI requested a review from CrSjimo August 15, 2026 17:40
@CrSjimo
CrSjimo merged commit 4464c07 into main Aug 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants