1

I have a library which

  • Loads audio files
  • Does filtering on the PCM data
  • Saves the new PCM back to files

it does that using:

  • Using its own implementation of load/save (raw files and uncompressed WAVE files)
  • Using the LAME library (MP3)
  • Using the ffmpeg library (all other formats)

Now I want to test that the ffmpeg implementation works as expected. I am thinking of:

  • Creating some audio samples in memory

  • Save them to an uncompressed WAVE file

  • Convert them to another format that the ffmpeg library supports using a command line such as:

    ffmpeg -i my-file.wav my-file.ogg
    
  • Load the my-file.ogg with my library

  • Compare to the audio samples I created in memory (first step above)

I'm not testing whether the ffmpeg library and tools work. I'm testing whether my software properly uses the ffmpeg library. So I would imagine that trying to load that my-file.ogg even though it was created by the ffmpeg command line tool, is a valid test as far as my software is concerned.

Am I correct or is that process flawed?

1
  • Could you clarify what you mean by "a library which loads audio files" and "my software properly uses the ffmpeg library"? I think it wasn't clear what is the purpose of your software and how it uses ffmpeg as a support. Commented May 21, 2021 at 6:09

1 Answer 1

1

Is it valid to use the tool that comes with a library to verify that your C/C++ code is working as expected?

Short answer is: Yes!

To me, it sounds like you are using a dependency (ffmpeg) to handle a specific task and you need to ensure that the output of that dependency is accurate so you can use that output in some way. So, you're not testing the dependency (ffmpeg) itself, but rather, the integration of that dependency.

You can certainly set this up as a unit test, since you're mainly dealing with an input/output validation. Or, you can setup this up as an integration test since you're dependent on integration a 3rd party dependency.

Either way, as this sounds like a critical part of your software, you need to ensure that it works, especially after you upgrade your dependency when new versions become available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.