Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 883217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:33:05+00:00 2026-05-15T12:33:05+00:00

I am currently working on a code base, that has never had any unit

  • 0

I am currently working on a code base, that has never had any unit tests written on it. It has been written for a 16-bit Embedded processor, and I would like to start to add unit tests for all the code that I write, at a minimum and then extend this to other parts of the code.

My problem with this is, I have found that each module (.c file) at the application level, seems to be tightly coupled to other C files in the project. For any given file, this may be anywhere from 2-10 files down.

  1. How do I start to write the unit tests?
  2. What are the best/quick/most efficient ways to remove this tight coupling?
  3. Also the unit tests will be run on the PC, (32 bit) and the embedded code is for a 16-bit processor. How do I ensure this is taken care of when porting the code to the PC?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:33:06+00:00Added an answer on May 15, 2026 at 12:33 pm

    Regarding #3 – making sure it is portable to PC, here’s the strategy I use:

    First, go through the embedded code and change any ‘int’ or ‘unsigned long’ to ‘int16’
    or ‘uint32’ (or whatever convention you choose).

    Wrap the section in the embedded header where you define the types inside a condition:

    #ifndef CORE_TYPE_DEFINITIONS
    #define CORE_TYPE_DEFINITIONS
    typedef long int16;
    /*...*/
    #endif
    

    create a “PC_Types.h” file which defines the same types for the PC.

    #ifdef CORE_TYPE_DEFINITIONS
    #error "Core Types already defined"
    #else
    #define CORE_TYPE_DEFINITIONS
    typedef short int16;
    /*...*/
    #endif
    

    In the PC project, create a wrapper for each embedded c file, which contains the following:

    #include "PC_Types.h"
    #include "ModuleX.c"  //the file under test
    
    #include "TestHarness.h"   //verification functions
    
    int TestModuleXUnit1(void)
    {
       /* setup */
       /* call Unit1(); */
       /* verify post-conditions */
       return result;
    }
    

    By wrapping every file, you have all the coupled functions available as needed. #including the original source file in your wrapper file allows you to drop in updates to the embedded code directly from your source control system without any modification. Adding the test functions after the included source gives the test code full access to all the module’s functions, even if they don’t have a public header.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 449k
  • Answers 449k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try setting the frame before you add it as a… May 15, 2026 at 8:10 pm
  • Editorial Team
    Editorial Team added an answer Whenever we deploy a change to a database object any… May 15, 2026 at 8:10 pm
  • Editorial Team
    Editorial Team added an answer I haven't used WCF Data Services for web forms development,… May 15, 2026 at 8:10 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.