Hi @usmanmarwat , CRAN runs what it is called "checks" which involves installation and running all of the package tests, and against several different operating systems. The results are publicly available, here is the link for the current results of ggplot2: CRAN Package Check Results for Package ggplot2
Regarding non-CRAN packages, as in the ones you get in a zip folder, since you have the source code, you should be able to open them in RStudio, and run the same checks CRAN does. In other words, it would be up to you to actually run the tests and verify the code.
Hope this helps.