[Thiago Cafe] Programming is fun!

About this blog

This blog is about programming and other technological things. Written by someone developing software for fun and professionally for longer than I want to admit and in more programming languages that I can remember

A simple guide to unit tests in Rust

(Posted 2024-02-27 06:15:19)

A very important part of any software are the unit tests, after all, they help us verifying that the cases that are in our heads are indeed correctly implemented and also that whoever is the next lucky fellow changing our code in the future (it might be ourselves!) will feel confident that their change won't break the application.

Rust implements tests in the same file that you are implementing your functions. I will first show one example and later explain how it works.

Creating the Unit Test

First, let's see a piece of code I used in a tool to generate posts for my newly rewritten blog system Texted2

... more ...

Pages: 1

About this blog

This blog is about programming and other technological things. Written by someone developing software for fun and professionally for longer than I want to admit and in more programming languages that I can remember