text: #include "common.h"
  
  int main(void) {
      char buffer[256 + 1] = {0};
      char buffer_b[8 + 1] = {0};
  
      libpath_get_component(1, "/home/user/music", buffer, 256);
      assert(strcmp(buffer, "user") == 0);
  
      libpath_get_component(0, "../home/user/music", buffer, 256);
      assert(strcmp(buffer, "..") == 0);
  
      libpath_get_component(1, "../home/user/music", buffer, 256);
      assert(strcmp(buffer, "home") == 0);
  
      libpath_get_component(3, "../home/user/music", buffer, 256);
      assert(strcmp(buffer, "music") == 0);
  
      libpath_get_component(0, "/home", buffer, 256);
      assert(strcmp(buffer, "home") == 0);
  
      libpath_get_component(0, "///", buffer, 256);
      assert(strcmp(buffer, "") == 0);
  
      libpath_get_component(1, "///", buffer, 256);
      assert(strcmp(buffer, "") == 0);
  
      libpath_get_component(2, "///", buffer, 256);
      assert(strcmp(buffer, "") == 0);
  
      libpath_get_component(0, "", buffer, 256);
      assert(strcmp(buffer, "") == 0);
  
      /* Buffer not big enough */
      libpath_get_component(2, "/home/user/music_folder", buffer_b, 8);
      assert(strcmp(buffer_b, "music_fo") == 0);
  
  
      return EXIT_SUCCESS;
  }
  