These tests assume that the underlying platform actually supports the d_type field.  Not every filesystem does, even if the operating system and libc do.  For example on Linux ext2/3/4 support it but FAT doesn't, resulting in TYPE_UNKNOWN coming back instead of the proper types.